← All Units← 返回单元列表 ← Course Hub← 课程主页
A P C O M P U T E R S C I E N C E P R I N C I P L E S
Unit 1 · Solutions第 1 单元 · 解析

Creative Development — Solutions创造性开发 —— 解析

Companion to the AP-Style MC Practice SetAP 风格选择题练习的解析配套

MEDIUM HARD AP MC

Unit 1: Creative Development第 1 单元:创造性开发CSP



MULTIPLE CHOICEWorked Answers详细解析

Multiple Choice — Worked Answers选择题(Multiple Choice)—— 详细解析

Each item restates the prompt and choices, marks the correct letter, and gives a brief justification. Trap distractors are called out where useful.每道题重述题干与选项、标出正确答案字母,并给出简明解析;对容易混淆的干扰项(trap distractor)单独提示。

Q1MEDIUMAP MC1.1 Collaboration

A team is designing a bus arrival app. Its initial prototype assumes that everyone can read small text and has a reliable Internet connection.一个团队正在设计公交到站应用程序。其初始原型(prototype)假设所有人都能阅读小字号文字,并且都有可靠的互联网连接。

Which action is most likely to improve the app by incorporating diverse perspectives?以下哪项行动最可能通过纳入不同视角来改进该应用程序?

Answer:答案: (C)
  • Potential users can reveal accessibility and connectivity needs that the developers missed.
  • The team can use those perspectives to revise the prototype.
Option A excludes user perspectives. Option B delays feedback and may add unsuitable features. Option D substitutes one person's preference for user evidence.
  • 潜在用户可以揭示开发者忽略的无障碍和网络连接需求。
  • 团队可以利用这些视角修改原型。
A 选项排除了用户视角。B 选项推迟反馈,可能添加不合适的功能。D 选项用个人偏好取代了用户证据。
Q2HARDAP MC1.1 Collaboration

Developers in different locations are building a community resource directory. They disagree about which search features to prioritize.身处不同地点的开发者正在构建社区资源目录。他们对应该优先开发哪些搜索功能存在分歧。

Which two actions would most directly support effective collaboration? Select two answers. Select two answers.以下哪两项行动最能直接促进有效协作(collaboration)?请选择两个答案。 选择两个答案。

Answer:答案: (A), (C)
  • A shared document makes proposals and feedback available across locations.
  • Discussing evidence and negotiating priorities helps the team resolve the disagreement.
Option B avoids communication and can produce incompatible work. Option D prevents useful review.
  • 共享文档使不同地点的成员都能查看提议和反馈。
  • 讨论证据并协商优先顺序有助于团队解决分歧。
B 选项回避沟通,可能导致工作成果不兼容。D 选项阻碍了有益的审阅。
Q3HARDAP MC1.1 Collaboration

Two students use pair programming to implement a procedure. One writes code while the other reviews the work and discusses possible test cases; they periodically exchange roles.两名学生使用结对编程(pair programming)实现一个过程。一人编写代码,另一人审阅并讨论可能的测试用例;他们定期交换角色。

Which explanation best describes a potential benefit of their approach?以下哪项最能说明这种方法的潜在好处?

Answer:答案: (A)
  • The reviewing partner can question assumptions and suggest tests while the code is being developed.
  • Switching roles gives both students opportunities to contribute.
Option B incorrectly treats collaboration as a guarantee of correctness. Option C overlooks the need to investigate requirements. Option D incorrectly replaces testing with review.
  • 审阅者可以在开发过程中质疑假设并提出测试建议。
  • 交换角色让两名学生都有机会作出贡献。
B 选项错误地认为协作能保证正确性。C 选项忽略了调查需求的必要性。D 选项错误地认为审阅可以取代测试。
Q4MEDIUMAP MC1.2 Program Function and Purpose

A program counts sensor readings that meet or exceed a threshold.一个程序统计达到或超过阈值(threshold)的传感器读数。

readings ← [3, 5, 5, 8, 2, 7]
count ← 0
FOR EACH value IN readings {
  IF(value ≥ 5) {
    count ← count + 1
  }
}
DISPLAY(count)

What value is displayed?显示的值是多少?

Answer:答案: (A)
  • The qualifying readings are 5, 5, 8, and 7.
  • The counter increases four times, so the program displays 4.
Option B counts only values greater than 5. Option C counts the repeated value 5 only once. Option D includes one reading below the threshold.
  • 符合条件的读数为 5、5、8 和 7。
  • 计数器增加四次,因此程序显示 4。
B 选项只计算大于 5 的值。C 选项把重复出现的 5 只计算一次。D 选项多计入了一个低于阈值的读数。
Q5HARDAP MC1.2 Program Function and Purpose

A developer uses two lists to prepare values for display.一位开发者使用两个列表(list)准备要显示的值。

a ← [4, 7, 9]
b ← a
REMOVE(b, 1)
b[1] ← 9
DISPLAY(a[2])
DISPLAY(b[1])

What values are displayed, in order?依次显示哪些值?

Answer:答案: (D)
  • Assigning a to b copies the list, so changes to b do not change a.
  • After the removal and assignment, b is [9, 9], while a remains [4, 7, 9].
  • The displayed values are 7 and 9.
Option A treats the lists as aliases. Option B overlooks the assignment to b[1]. Option C uses the first element of a instead of its second.
  • 将 a 赋给 b 会复制列表,因此对 b 的修改不会改变 a。
  • 删除和赋值后,b 为 [9, 9],而 a 仍为 [4, 7, 9]。
  • 显示的值依次为 7 和 9。
A 选项错误地把两个列表视为同一列表的别名。B 选项忽略了对 b[1] 的赋值。C 选项使用了 a 的第一个元素,而不是第二个。
Q6HARDAP MC1.2 Program Function and Purpose

An art app waits for the user to tap a color button. The tap causes the app to read the selected color and change the color displayed on the canvas.一个绘画应用程序等待用户点击颜色按钮。点击后,应用程序读取所选颜色,并改变画布上显示的颜色。

Which description correctly identifies the event, input, and output?以下哪项正确识别了事件(event)、输入(input)和输出(output)?

Answer:答案: (D)
  • The tap triggers the app's response, making it an event.
  • The selected color is data used by the app, and the changed canvas is data sent to a display.
Option A confuses the trigger and the displayed result. Option B reverses input and output. Option C misidentifies all three roles.
  • 点击触发应用程序的响应,因此它是事件。
  • 所选颜色是应用程序使用的数据,改变后的画布则是发送到显示设备的数据。
A 选项混淆了触发动作和显示结果。B 选项颠倒了输入与输出。C 选项错误识别了这三种角色。
Q7HARDAP MC1.2 Program Function and Purpose

A robot is on a 3-by-3 grid. Columns increase from left to right and rows increase from bottom to top. The robot starts at column 2, row 1, facing north. The only black square is column 2, row 3; all other squares are open.一个机器人位于 3 行 3 列的网格上。列号从左到右递增,行号从下到上递增。机器人从第 2 列第 1 行出发,面向北方。唯一的黑色方格位于第 2 列第 3 行;其他方格均可通行。

REPEAT 3 TIMES {
  IF(CAN_MOVE(forward)) {
    MOVE_FORWARD()
  } ELSE {
    ROTATE_RIGHT()
  }
}

Where is the robot, and which direction is it facing, after the program finishes?程序结束后,机器人位于何处,面向哪个方向?

Answer:答案: (A)
  • On the first pass the robot moves to (2, 2).
  • The black square blocks forward movement on the second pass, so it rotates east without moving.
  • On the third pass it moves to (3, 2), still facing east.
Option B ignores the rotation. Option C omits the third pass. Option D ignores the change in direction.
  • 第一次循环时,机器人移动到 (2, 2)。
  • 第二次循环时,前方的黑色方格挡住去路,因此机器人原地右转,面向东。
  • 第三次循环时,机器人移动到 (3, 2),仍面向东。
B 选项忽略了转向。C 选项遗漏了第三次循环。D 选项忽略了方向的改变。
Q8MEDIUMAP MC1.3 Program Design and Development

A team builds a basic appointment app, tests it with users, revises the scheduling screen, and tests the revised screen again.一个团队先构建基本的预约应用程序,再让用户测试,根据反馈修改预约界面,然后再次测试修改后的界面。

Which description best characterizes this development process?以下哪项最能描述这一开发过程?

Answer:答案: (C)
  • The team uses feedback to revise an existing design.
  • Testing the revision continues the cycle, which is iterative.
Option A ignores the return to revision and testing. Option B overlooks user testing as a form of investigation. Option D assumes that testing guarantees correctness.
  • 团队利用反馈修改已有设计。
  • 对修改后的设计再次测试,延续了这一循环,因此属于迭代式开发(iterative development)。
A 选项忽略了返回修改和测试的过程。B 选项忽略了用户测试也是一种调查方式。D 选项错误地认为测试能保证正确性。
Q9HARDAP MC1.3 Program Design and Development

A developer maintains a program that calculates library fines. A comment says that a procedure returns a fine in cents, but the procedure was recently changed to return dollars.一位开发者维护一个计算图书馆罚款的程序。一条注释(comment)说明某过程返回以分为单位的罚款,但该过程最近已改为返回以元为单位的金额。

Which action best supports future maintenance?以下哪项行动最有利于今后的维护?

Answer:答案: (B)
  • Accurate documentation communicates the procedure's current behavior.
  • Code that consumes the result may also need revision because the unit changed.
Option A leaves documentation that is now inaccurate, and comments never control the returned unit (CRD-2.G.2). Option C discards useful maintenance information. Option D edits only the comment and assumes the code follows; comments do not affect how a program runs, so callers must still be checked.
  • 准确的文档能说明过程当前的行为。
  • 由于单位发生变化,使用该结果的代码也可能需要修改。
A 选项留下了已经不准确的文档,而且注释从不决定返回值的单位(CRD-2.G.2)。C 选项丢弃了有助于维护的信息。D 选项只改注释,并假定代码会随之改变;注释不影响程序运行,所以仍需检查调用方。
Q10HARDAP MC1.3 Program Design and Development

A student adapts a code segment written by another programmer for a class project. The student also modifies the segment to meet the project's requirements.一名学生为课堂项目改用了另一位程序员编写的代码片段(code segment),并对其进行了修改以满足项目要求。

Which documentation practice appropriately acknowledges the source?以下哪种文档做法适当地注明了来源?

Answer:答案: (D)
  • The segment originated with another programmer, even though the student adapted it.
  • Documentation can acknowledge the original author or source and identify the reused work.
Option A omits the original contribution. Option B makes a false authorship claim. Option C improperly makes acknowledgment depend on an error.
  • 尽管学生修改了代码,该片段仍源自另一位程序员。
  • 文档可以注明原作者或来源,并指出复用的内容。
A 选项遗漏了原作者的贡献。B 选项对代码作者作了虚假声明。C 选项错误地将是否注明来源取决于代码是否出错。
Q11HARDAP MC1.3 Program Design and Development

A team is designing an app for reporting broken streetlights. The team has not yet decided which information the app should request or how reports should be submitted.一个团队正在设计用于报告路灯故障的应用程序。团队尚未确定应用程序应要求用户提供哪些信息,也未确定报告应如何提交。

Which two actions would help establish requirements before finalizing the design? Select two answers. Select two answers.在确定最终设计之前,以下哪两项行动有助于制定需求(requirements)?请选择两个答案。 选择两个答案。

Answer:答案: (A), (C)
  • Interviews reveal information needs and constraints from different participants.
  • Observation of prototype use can reveal interaction problems and additional requirements.
Option B substitutes an unsupported assumption for investigation. Option D prioritizes implementation convenience without establishing user needs.
  • 访谈可以揭示不同参与者的信息需求和限制条件。
  • 观察用户使用原型可以发现交互问题和其他需求。
B 选项用未经证实的假设取代调查。D 选项在未确定用户需求的情况下优先考虑实现的便利性。
Q12HARDAP MC1.4 Identifying and Correcting Errors

A developer runs the following code to display every value in a list.一位开发者运行以下代码,以显示列表中的每个值。

values ← [2, 5, 8]
i ← 1
REPEAT 4 TIMES {
  DISPLAY(values[i])
  i ← i + 1
}

What is displayed before the program terminates due to an error?程序因错误终止之前显示了什么?

Answer:答案: (C)
  • Indices 1, 2, and 3 are valid and display 2, 5, and 8.
  • On the fourth pass, index 4 is outside the list, so a run-time error terminates the program.
Option A stops one pass too early. Option B assumes an invalid index repeats the last value. Option D overlooks the displays before the error.
  • 索引 1、2 和 3 有效,分别显示 2、5 和 8。
  • 第四次循环时,索引 4 超出列表范围,运行时错误(run-time error)使程序终止。
A 选项过早停止了一次循环。B 选项错误地假设无效索引会重复最后一个值。D 选项忽略了错误发生前的显示。
Q13HARDAP MC1.4 Identifying and Correcting Errors

A developer tests a loop with an initial value at the stopping boundary.一位开发者用停止边界上的初始值测试一个循环。

n ← 5
total ← 0
REPEAT UNTIL(n ≥ 5) {
  total ← total + n
  n ← n + 1
}
DISPLAY(total)

What value is displayed?显示的值是多少?

Answer:答案: (B)
  • The condition n ≥ 5 is true before the first pass.
  • The loop body does not run, so total remains 0.
Option A assumes the body runs once before the condition is checked. Option C confuses the next value of n with total. Option D incorrectly adds the boundary value twice.
  • 第一次执行循环体之前,条件 n ≥ 5 已经为真。
  • 循环体不执行,因此 total 仍为 0。
A 选项错误地认为检查条件前循环体会先执行一次。C 选项混淆了 n 的下一个值与 total。D 选项错误地把边界值加了两次。
Q14HARDAP MC1.4 Identifying and Correcting Errors

A procedure is intended to sum the positive even integers up to and including its parameter. A developer tests it with 8.一个过程(procedure)旨在求出不超过其参数的所有正偶数之和,包含参数本身。一位开发者使用 8 进行测试。

PROCEDURE sumEven(limit) {
  i ← 1
  total ← 0
REPEAT UNTIL(i > limit) {
    IF(i MOD 2 = 0) {
      total ← total + i
    }
    i ← i + 1
  }
  RETURN(total)
}
DISPLAY(sumEven(8))

What value does this test display?此次测试显示什么值?

Answer:答案: (B)
  • The loop checks each integer from 1 through 8.
  • The values with remainder 0 when divided by 2 are 2, 4, 6, and 8.
  • Their sum is 20.
Option A omits the inclusive endpoint 8. Option C omits 4. Option D adds every integer rather than only the even integers.
  • 循环检查从 1 到 8 的每个整数。
  • 除以 2 的余数为 0 的值是 2、4、6 和 8。
  • 它们的和为 20。
A 选项遗漏了应包含的端点 8。C 选项遗漏了 4。D 选项把所有整数都相加,而不是只加偶数。
Q15MEDIUMAP MC1.4 Identifying and Correcting Errors

A program must accept integer ages from 0 through 120, inclusive, and reject all other integer ages.一个程序必须接受从 0 到 120 的整数年龄,包括两个端点,并拒绝其他所有整数年龄。

Which set of test inputs best checks both boundaries and values just outside them?以下哪组测试输入最适合检查两个边界以及恰好位于边界之外的值?

Answer:答案: (A)
  • The requirements accept 0 and 120.
  • They reject -1 and 121, which are immediately outside the permitted range.
Option B does not test either endpoint or an outside value. Option C omits values just outside the range. Option D omits the accepted endpoints and immediate outside values.
  • 根据需求,程序应接受 0 和 120。
  • 程序应拒绝 -1 和 121,它们恰好位于允许范围之外。
B 选项既没有测试端点,也没有测试范围外的值。C 选项遗漏了恰好位于范围之外的值。D 选项遗漏了应接受的端点和紧邻范围之外的值。