Back to Challenge Set 8

Question Set 4

Difficulty  

divider

What This Is

Six exam-style questions, mostly about loops — Activity 1.17. These sets are cumulative, so randomness, conditions, and Part 0 are all still fair game.

The AP exam gives you 70 questions in 120 minutes, which is 1 minute 43 seconds each.

How to Do This One

  • Set a timer for 10 minutes before you start. That is two less than last time, on purpose. The questions are shorter and you have done three of these already; the target from here is exam pace, not comfort.
  • When the timer ends, stop. Mark anything unfinished as unfinished — that is real information, not a failure.
  • Work them out. Do not run the code. On exam day there is no computer.
  • For each question, also write sure or unsure. This is graded on completion, so an honest unsure costs you nothing and tells us both where to look.

Guessing beats leaving it blank. There is no penalty for a wrong answer on the AP exam, so a blank is a guaranteed zero where a guess is not.


The Questions

Four have exactly one correct answer, one asks you to select all that apply, and the last is about data or the impact of computing rather than about code. Thirteen of the exam's seventy questions look like that last one, so it is on every set from here on.


Question 1 — Select all that apply

Which of the following loops never stop?

A
int n = 5;
while (n > 0)
{
Console.WriteLine(n);
}
B
int n = 5;
while (n > 0)
{
n = n - 1;
}
C
int n = 5;
while (n != 0)
{
n = n - 2;
}
D
int n = 0;
while (n < 3)
{
n = n + 1;
}

Question 2

The following is written in AP exam notation. How many times does the body of this loop run?

Question 2
count ← 3
REPEAT UNTIL(count = 0)
{
DISPLAY(count)
count ← count - 1
}
  1. 0
  2. 2
  3. 3
  4. It never stops.

Question 3

What does the program in Question 2 display?

  1. 3 2 1
  2. 3 2 1 0
  3. 2 1 0
  4. 1 2 3

Question 4

A student translates while (x < 10) from C# into exam notation as REPEAT UNTIL(x < 10). What have they done wrong?

  1. Nothing; the two are equivalent.
  2. REPEAT UNTIL runs until its condition becomes true, so the condition must be inverted to x ≥ 10.
  3. REPEAT UNTIL requires a counter variable.
  4. < is not a valid operator in exam notation.

Question 5

What does the following C# display?

Question 5
int fuel = 0;
while (fuel < 500)
{
fuel = fuel + 120;
}
Console.WriteLine(fuel);
  1. 480
  2. 500
  3. 600
  4. Nothing — the loop never ends.

Question 6 — Data and Impact

Which of the following is the best description of a computing innovation?

  • (A) Any device that uses electricity.
  • (B) Anything that includes a program as part of how it works.
  • (C) Any program written in the last ten years.
  • (D) Any app available on a phone.

Submit

  • Your answer to each question, with sure or unsure
  • Whether you finished inside 10 minutes, and if not, how far you got
  • One sentence: which question took you longest, and what slowed you down?

This is graded on completion, not accuracy. A thoughtful wrong answer earns the same as a right one. What is being built here is speed and stamina, and both require being allowed to get things wrong cheaply.

Start the Timer