Practice Questions · AP CSP-Feeder · US / ON / BC / AB Styles练习题集 · AP CSP 衔接 · 美 / 安 / 卑 / 阿省风格
Questions mix multiple-choice and short-answer items. For MCQs, circle the letter of the best answer and briefly justify your choice in the work space. For short-answer items, write clearly. No code tracing is required in Part I; questions focus on SDLC concepts, requirements, design tools, coding standards, and error classification.本部分包含选择题与短答题。选择题请圈出最佳答案的字母并在答题空白处简要说明理由。短答题清晰书写。第一部分无需追踪代码;题目聚焦于 SDLC 概念、需求、设计工具、编码规范和错误分类。
A software team is creating flowcharts, pseudocode, and UML diagrams to plan their program structure before writing any code. Which phase of the Software Development Life Cycle (SDLC) are they in?一个软件团队在编写任何代码之前,正在创建流程图、伪代码和 UML 图来规划程序结构。他们处于软件开发生命周期(SDLC)的哪个阶段?
A team is building a school portal app. Read the four requirements below and classify each as Functional (F) or Non-functional (NF).一个团队正在构建学校门户应用程序。阅读以下四个需求,将每个需求分类为功能性(F)或非功能性(NF)。
Read the pseudocode below for a login validation function.阅读以下登录验证函数的伪代码。
FUNCTION validate_login(username, password)
IF username == stored_username AND password == stored_password THEN
OUTPUT "Access granted"
RETURN True
ELSE
OUTPUT "Access denied"
RETURN False
END IF
END FUNCTION
A student submits the following Python code. It runs correctly but violates multiple coding standards.一名学生提交了以下 Python 代码。它运行正确,但违反了多条编码规范。
x = float(input("enter: "))
if x > 37:
print("fever") # high
else:
print("normal")
Match each code snippet or scenario below with the correct error type: Syntax, Logic, or Runtime.将以下每个代码片段或场景与正确的错误类型匹配:语法、逻辑或运行时。
scores = [85, 92, 78]
print(scores[5]) # list has only 3 elements
Name the error type and explain why it occurs at runtime, not at parse time.命名错误类型并解释为什么它在运行时而非解析时发生。 [2]
def add(a, b)
return a + b
Name the error type and identify the exact mistake.命名错误类型并指出确切错误。 [2]
if score > 90 instead of if score >= 90. Name the error type and explain why the program does not crash.一个成绩程序在输入分数为 90 时输出"B"。程序员希望分数 90 输出"A"。程序使用 if score > 90 而非 if score >= 90。命名错误类型并解释程序为何不崩溃。 [3]Answer all sub-parts with complete sentences where prose is requested. Where pseudocode or code is requested, use the standard block format with correct indentation. Two sentences of reasoning earn full marks on "explain" and "justify" questions. Calculator not applicable.需要散文的子问题用完整句子作答。需要伪代码或代码时,使用标准块格式并正确缩进。"解释"和"论证"题两句推理即可满分。无需计算器。
Two student teams are building apps. Team Alpha is designing a library management system for a school with fixed, well-understood requirements. Team Beta is building a social study-group app where users are expected to request new features every two weeks.两个学生团队正在开发应用程序。阿尔法团队正在为学校设计一个图书馆管理系统,需求固定且已明确。贝塔团队正在构建一个社交学习小组应用,用户预计每两周提出新功能需求。
A program accepts a temperature in Celsius and outputs a description. The logic is shown below.一个程序接受摄氏温度并输出描述。逻辑如下所示。
FUNCTION describe_temp(celsius)
IF celsius < 0 THEN
OUTPUT "Freezing"
ELSE IF celsius < 15 THEN
OUTPUT "Cold"
ELSE IF celsius < 30 THEN
OUTPUT "Comfortable"
ELSE
OUTPUT "Hot"
END IF
END FUNCTION
| Scenario场景 | Input (celsius)输入(celsius) | Expected output预期输出 | Type类型 |
|---|---|---|---|
| Normal -- comfortable day正常 -- 舒适的一天 | 22 | Normal正常 | |
| Normal -- freezing day正常 -- 冰冻的一天 | -10 | Normal正常 | |
| Boundary边界 | |||
| Error/Edge错误/边缘 |
0 and observes the output is "Cold", but expected "Freezing". Identify the error type and explain what boundary condition the programmer got wrong.一名学生用输入 0 测试,观察到输出为 "Cold",但期望是 "Freezing"。识别错误类型,并解释程序员在哪个边界条件上出错了。 [2]Read the function below. It is missing a docstring and has no inline comments.阅读以下函数。它缺少文档字符串且没有内联注释。
def convert_grade(score):
if not (0 <= score <= 100):
raise ValueError("out of range")
A, B, C, D = 90, 80, 70, 60
if score >= A:
return "A"
elif score >= B:
return "B"
elif score >= C:
return "C"
elif score >= D:
return "D"
else:
return "F"
convert_grade. Your docstring must include: a one-sentence description, the parameter name and type, the return type, and the exception that can be raised.为 convert_grade 编写一个正确的 Python 文档字符串。文档字符串必须包括:一句话描述、参数名称和类型、返回类型以及可能引发的异常。 [4]A student submits the code below. A code reviewer has flagged it for multiple violations of coding standards and missing documentation.一名学生提交了以下代码。代码审查员标记了多个编码规范违规和缺失文档的问题。
def f(l):
t = 0
for i in l:
if i > 0:
t = t + i
return t # add
Read each scenario carefully before writing. Use standard pseudocode block format (IF/THEN/END IF, WHILE/END WHILE, FUNCTION/END FUNCTION) where pseudocode is requested. Where Python is requested, show indentation correctly. Conclude each question with a one-sentence summary answer.动笔前仔细阅读每个场景。需要伪代码时使用标准块格式(IF/THEN/END IF、WHILE/END WHILE、FUNCTION/END FUNCTION)。需要 Python 时正确显示缩进。每题以一句完整的总结句作答。
A school team is building a locker assignment system. When a student enters their name, the system outputs an available locker number and marks it as taken. If no lockers are available, the system outputs an error message.一个学校团队正在构建一个储物柜分配系统。当学生输入姓名时,系统输出一个可用的储物柜编号并将其标记为已占用。如果没有可用储物柜,系统输出错误信息。
assign_locker(name) function. Assume lockers is a list of available locker numbers. Your pseudocode must handle the case where no lockers remain.为 assign_locker(name) 函数编写伪代码。假设 lockers 是可用储物柜编号的列表。伪代码必须处理没有可用储物柜的情况。 [3]LockerSystem class. Include at least two attributes and two methods that correspond to your pseudocode design.为 LockerSystem 类绘制简单的 UML 类图(文本/ASCII 格式)。至少包括两个属性和两个与伪代码设计对应的方法。 [2]Two students (Anika and Ben) are collaborating on a password strength checker. The function check_strength(pwd) returns "Strong" if the password has 8 or more characters and contains at least one digit; otherwise it returns "Weak".两名学生(阿妮卡和本)正在合作开发一个密码强度检查器。函数 check_strength(pwd) 若密码至少 8 个字符且包含至少一个数字则返回 "Strong";否则返回 "Weak"。
| Scenario场景 | Input (pwd)输入(pwd) | Expected output预期输出 | Type类型 |
|---|---|---|---|
| Normal (strong)正常(强) | |||
| Normal (weak)正常(弱) | |||
| Boundary边界 | |||
| Edge边缘 |
check_strength("abcdefg1") returns "Weak" when it should return "Strong" (the password has exactly 8 characters including one digit). Write the three Git commands she would use, in order, to stage her bug fix, save a snapshot, and upload to the remote repository. Use a meaningful commit message.阿妮卡发现一个错误:check_strength("abcdefg1") 返回 "Weak",但应该返回 "Strong"(密码恰好有 8 个字符包含一个数字)。按顺序写出她会使用的三个 Git 命令,以暂存修复、保存快照并上传到远程仓库。使用有意义的提交消息。 [3]password_checker.py at the same time.说明当阿妮卡和本同时编辑 password_checker.py 时,使用 Git 分支的一个重要原因。 [1]A student team is building a cafeteria menu voting app. Students can vote for their preferred lunch item from a list of 5 options. The app tracks vote counts and announces the winner at the end of the day. The team is using agile development with two-week sprints and collaborating via Git.一个学生团队正在构建一个食堂菜单投票应用。学生可以从 5 个选项列表中为喜欢的午餐投票。应用跟踪投票计数并在一天结束时宣布获胜者。团队使用两周冲刺的敏捷开发并通过 Git 协作。
IndexError. Identify the error type, name the SDLC phase where this failure should have been caught, and describe one specific test case that would have revealed it.团队发现当两个食品的投票数相同时,应用以 IndexError 崩溃。识别错误类型,命名本应捕获该故障的 SDLC 阶段,并描述一个能够发现它的具体测试用例。 [3]CRD-2.A · 3B-AP-17 · 3B-AP-21ICS3U B4.1 · B4.4 · ICS4U B1.7Full Syllabus Map in Study Guide: ../Study Guides/Unit_13_Software_Development_Process.html. CS has no AB standalone diploma exam; AB framing uses CSE outcomes.完整大纲对照见学习指南:../Study Guides/Unit_13_Software_Development_Process.html。CS 无独立 AB 毕业考;AB 题使用 CSE 结果框架。