← Course Hub← 课程主页 ← All Units← 返回单元列表
H I G H  S C H O O L  C O M P U T E R  S C I E N C E
Practice练习题

Software Development Process软件开发流程

Practice Questions · AP CSP-Feeder · US / ON / BC / AB Styles练习题集 · AP CSP 衔接 · 美 / 安 / 卑 / 阿省风格

EASY MEDIUM HARD 🇺🇸 US 🇨🇦 ON 🇨🇦 BC 🇨🇦 AB AP CSP-style MCQAP CSP 风格选择题 AP CSP-feeder FRQAP CSP 衔接简答题 ON Provincial-style安大略省考风格 BC Provincial-style卑诗省考风格 AB/Universal Applied阿省/通用应用题 Honors荣誉级


Name:姓名:Date:日期:
PART I  ·  SHORT RESPONSE第一部分  ·  短答题AP CSP-style MCQ + ON/BC short answer · 25 marksAP CSP 风格选择题 + 安/卑省考短答 · 共 25 分

Section A · Short ResponseA 部分 · 短答题

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 概念、需求、设计工具、编码规范和错误分类。

Q1 EASY 🇺🇸 US AP CSP-style MCQAP CSP 风格选择题 §1 SDLC PhasesSDLC 阶段 · CSTA 3B-AP-17 [3 marks][3 分]

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)的哪个阶段?

  1. (A) Requirements需求
  2. (B) Design设计
  3. (C) Testing测试
  4. (D) Maintenance维护
Q2 EASY 🇨🇦 ON ON Provincial-style安大略省考风格 §2 Functional vs Non-functional Requirements功能性与非功能性需求 · ICS3U B4.1 [4 marks][4 分]

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)

  1. The portal shall allow students to view their current grades.门户应允许学生查看当前成绩。
  2. The portal shall load any page in under 3 seconds on a standard Wi-Fi connection.门户应在标准 Wi-Fi 连接下 3 秒内加载任意页面。
  3. The portal shall allow teachers to post assignment due dates.门户应允许教师发布作业截止日期。
  4. The portal shall store all passwords in encrypted form, never as plain text.门户应以加密形式存储所有密码,绝不使用明文。
(a) Classify each requirement as F or NF. Write only the item number and classification (e.g., 1 = F).将每个需求分类为 F 或 NF。只写条目编号和分类(例如,1 = F)。 [2]
(b) Explain in one sentence the key difference between a functional and a non-functional requirement.用一句话解释功能性需求与非功能性需求的关键区别。 [2]
Q3 MEDIUM 🇨🇦 BC BC Provincial-style卑诗省考风格 §3 Design Artifacts设计制品 · ICS3U B2.4 [5 marks][5 分]

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) Identify one input and one output of this function as shown in the pseudocode.根据伪代码,识别该函数的一个输入和一个输出。 [2]
(b) A UML class diagram has three sections. Name all three sections and state what each contains.UML 类图有三节。命名全部三节并说明每节包含的内容。 [2]
(c) State which design tool (pseudocode, flowchart, or UML class diagram) is best suited for showing the attributes and methods of a class. Justify in one sentence.说明哪种设计工具(伪代码、流程图或 UML 类图)最适合显示类的属性和方法。用一句话说明理由。 [1]
Q4 MEDIUM 🇨🇦 AB AB/Universal Applied阿省/通用应用题 §4 Coding Standards编码规范 · CSE1120 · BC CP11 [6 marks][6 分]

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")
(a) Identify three specific coding standard violations in this code. For each, name the standard violated and describe the violation.在此代码中找出三个具体的编码规范违规。对每个违规,命名所违反的规范并描述违规之处。 [3]
(b) Rewrite the code to fix all three violations. Preserve the same logic.重写代码以修复所有三个违规。保持相同的逻辑。 [3]
Q5 MEDIUM 🇺🇸 US 🇨🇦 ON AP CSP-style MCQAP CSP 风格选择题 §5 Error Types错误类型 · BC CP11 · ICS3U B4.4 [7 marks][7 分]

Match each code snippet or scenario below with the correct error type: Syntax, Logic, or Runtime.将以下每个代码片段或场景与正确的错误类型匹配:语法逻辑运行时

(a)
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]
(b)
def add(a, b)
    return a + b
Name the error type and identify the exact mistake.命名错误类型并指出确切错误。 [2]
(c) A grade program outputs "B" when the input score is 90. The programmer intended score 90 to output "A". The program uses 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]
PART II  ·  EXTENDED RESPONSE第二部分  ·  简答题AP CSP-feeder FRQ + Honors · 30 marksAP CSP 衔接简答题 + 荣誉级 · 共 30 分

Section B · Extended ResponseB 部分 · 简答题

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.需要散文的子问题用完整句子作答。需要伪代码或代码时,使用标准块格式并正确缩进。"解释"和"论证"题两句推理即可满分。无需计算器。

Q6 EASY 🇺🇸 US AP CSP-feeder FRQAP CSP 衔接简答题 §1 Waterfall vs Agile瀑布模型与敏捷 · CSTA 3B-AP-17 [5 marks][5 分]

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) State which development model (waterfall or agile) is more appropriate for Team Alpha. Justify your choice in two sentences.说明哪种开发模型(瀑布或敏捷)更适合阿尔法团队。用两句话说明理由。 [2]
(b) State which model is more appropriate for Team Beta. Name one specific advantage of that model for their situation.说明哪种模型更适合贝塔团队。针对他们的情况,说明该模型的一个具体优点。 [2]
(c) Name one disadvantage of the waterfall model compared to agile.与敏捷相比,说明瀑布模型的一个缺点。 [1]
Q7 MEDIUM 🇨🇦 ON ON Provincial-style安大略省考风格 §5 Test Plan测试计划 · ICS3U B4.4 [8 marks][8 分]

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
(a) Complete the test plan table below. Fill in the expected outputs for the first two rows, then add one boundary test case and one error/edge test case of your own in the last two rows.补全以下测试计划表。填写前两行的预期输出,然后在最后两行自行添加一个边界测试用例和一个错误/边缘测试用例。 [4]
Scenario场景Input (celsius)输入(celsius)Expected output预期输出Type类型
Normal -- comfortable day正常 -- 舒适的一天22Normal正常
Normal -- freezing day正常 -- 冰冻的一天-10Normal正常
Boundary边界
Error/Edge错误/边缘
(b) According to Ontario ICS3U B4.4, what are the four required elements of a test plan? List them.根据安大略 ICS3U B4.4,测试计划的四个必要要素是什么?列出它们。 [2]
(c) A student tests with input 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]
Q8 HARD 🇨🇦 BC 🇺🇸 US AP CSP-feeder FRQAP CSP 衔接简答题 §6 Documentation and Maintenance文档与维护 · CSTA 3B-AP-22 · BC CP12 [8 marks][8 分]

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"
(a) Write a proper Python docstring for 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]
(b) Name the three types of software maintenance (corrective, adaptive, perfective) and give one concrete example of each as it might apply to this grade calculator function after release.命名三种软件维护类型(纠正性、适应性、完善性),并各举一个在该成绩计算器函数发布后可能适用的具体例子。 [3]
(c) State which documentation type (inline comments, technical documentation, or user documentation) a Python docstring belongs to, and identify its intended audience.说明 Python 文档字符串属于哪种文档类型(内联注释、技术文档或用户文档),并识别其目标受众。 [1]
Q9 HARD Honors荣誉级 🇺🇸 US AP CSP-feeder FRQAP CSP 衔接简答题 §4 + §6 Code Standards + Refactoring编码规范 + 重构 · CSTA 3B-AP-23 [9 marks][9 分]

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
(a) Identify four specific problems with this code (considering naming conventions, comment quality, and missing documentation). For each problem, state what it is and cite the relevant coding standard.识别此代码的四个具体问题(考虑命名规范、注释质量和缺失文档)。对每个问题,说明问题是什么并引用相关编码规范。 [4]
(b) Rewrite the function to meet professional coding standards. Include: a docstring with description, parameter, and return type; meaningful names; one useful inline comment; and use of a named constant where appropriate. Preserve the same logic.重写函数以满足专业编码规范。包括:含描述、参数和返回类型的文档字符串;有意义的命名;一条有用的内联注释;并在适当位置使用命名常量。保持相同的逻辑。 [4]
(c) CSTA 3B-AP-23 requires "evaluating key qualities of a program through a code review." Name two qualities a code reviewer checks beyond whether the code runs correctly.CSTA 3B-AP-23 要求"通过代码审查评估程序的关键质量"。说明代码审查员除验证代码是否正确运行之外检查的两个质量。 [1]
PART III  ·  MODELING / APPLIED第三部分  ·  建模与应用Universal / multi-region applied · 25 marks通用/多地区应用题 · 共 25 分

Section C · Modeling and ApplicationsC 部分 · 建模与应用

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 时正确显示缩进。每题以一句完整的总结句作答。

Q10 MEDIUM 🇺🇸 US 🇨🇦 ON AP CSP-feeder FRQAP CSP 衔接简答题 §2 + §3 Requirements + Design需求 + 设计 · CRD-2.A · ICS3U B2.4 [8 marks][8 分]

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.一个学校团队正在构建一个储物柜分配系统。当学生输入姓名时,系统输出一个可用的储物柜编号并将其标记为已占用。如果没有可用储物柜,系统输出错误信息。

(a) Write two numbered functional requirements (FR-1, FR-2) and one numbered non-functional requirement (NFR-1) for this system. Each requirement must be specific and testable.为该系统编写两个编号功能性需求(FR-1、FR-2)和一个编号非功能性需求(NFR-1)。每个需求必须具体且可测试。 [3]
(b) Write pseudocode for an 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]
(c) Draw a simple UML class diagram (in text/ASCII format) for a LockerSystem class. Include at least two attributes and two methods that correspond to your pseudocode design.LockerSystem 类绘制简单的 UML 类图(文本/ASCII 格式)。至少包括两个属性和两个与伪代码设计对应的方法。 [2]
Q11 MEDIUM 🇨🇦 ON 🇨🇦 BC ON Provincial-style安大略省考风格 §5 + §7 Testing + Version Control测试 + 版本控制 · ICS4U B1.7 · BC CP11 [8 marks][8 分]

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"

(a) Design a test plan with four test cases: one normal "strong", one normal "weak", one boundary, and one edge case. Fill in the scenario, input, expected output, and type for each row.设计包含四个测试用例的测试计划:一个正常"强"、一个正常"弱"、一个边界和一个边缘情况。填写每行的场景、输入、预期输出和类型。 [4]
Scenario场景Input (pwd)输入(pwd)Expected output预期输出Type类型
Normal (strong)正常(强)
Normal (weak)正常(弱)
Boundary边界
Edge边缘
(b) Anika finds a bug: 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]
(c) State one reason why using Git branches is important when both Anika and Ben are editing password_checker.py at the same time.说明当阿妮卡和本同时编辑 password_checker.py 时,使用 Git 分支的一个重要原因。 [1]
Q12 HARD 🇺🇸 US 🇨🇦 ON 🇨🇦 BC AP CSP-feeder FRQAP CSP 衔接简答题 §1 + §3 + §5 + §7 Full SDLC Scenario完整 SDLC 场景 · CSTA 3B-AP-17 · ICS3U B4.1 [9 marks][9 分]

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 协作。

(a) Map the team's work to five SDLC phases. For each phase (Requirements, Analysis, Design, Implementation, Testing), give one specific activity this team would perform for the voting app.将团队的工作映射到五个 SDLC 阶段。对每个阶段(需求、分析、设计、实现、测试),给出该团队在投票应用中会执行的一个具体活动。 [5]
(b) The team discovers that when two food items have the same vote count, the app crashes with an 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]
(c) Explain in one sentence why the agile model is a better fit than waterfall for this voting app, given that the school cafeteria menu changes each term.解释为什么考虑到学校食堂每学期菜单变化,敏捷模型比瀑布模型更适合这个投票应用。用一句话解释。 [1]

🇺🇸 US CSTA / AP CSP美国 CSTA / AP CSPCRD-2.A · 3B-AP-17 · 3B-AP-21
🇨🇦 Ontario安大略ICS3U B4.1 · B4.4 · ICS4U B1.7
🇨🇦 British Columbia不列颠哥伦比亚CP11/CP12: SDLC, inline comments, collaboration toolsCP11/CP12:SDLC、内联注释、协作工具
🇨🇦 Alberta阿尔伯塔CSE1110 outcome 1.7 · CSE1120 · CSE3120CSE1110 结果 1.7 · CSE1120 · CSE3120

Full 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 结果框架。