AP Computer Science Principles Practice Quiz

Practice data representation, collaboration, computing systems, and pseudocode. Work up to tracing list changes and procedure calls, evaluating test cases, and reasoning about parallel execution.

Ages 14+ · AP Computer Science Principles students and classroom review

Question 1 of 15

$100

A school archives a spreadsheet of exact measurement readings. It needs to recover every original digit after decompression. Which approach meets that requirement?

Ready to play?

Open at Step 3 with every question loaded. Play solo, host live, or customize your game.

Play & Customize Game

Questions by ladder level

Level 1 · Data compression

A school archives a spreadsheet of exact measurement readings. It needs to recover every original digit after decompression. Which approach meets that requirement?

  1. Use lossless compression
  2. Round each reading before storing it
  3. Store one average per group of readings
  4. Drop the final digit of each reading
Show answer and explanation

Correct answer: A. Use lossless compression

Lossless compression allows exact recovery of the original data. Rounding, averaging, and dropping digits change or discard information.

Question reference

Level 2 · Online collaboration

A public library invites volunteers to supply descriptive tags for photographs in its online archive. The library combines the volunteers' contributions. What approach does this illustrate?

  1. Random sampling
  2. Parallel execution
  3. Crowdsourcing
  4. Lossless compression
Show answer and explanation

Correct answer: C. Crowdsourcing

Crowdsourcing gathers contributions from a group of people. Here the volunteers contribute knowledge that helps others find photographs.

Question reference

Level 3 · Shared protocols

Two devices from different manufacturers exchange messages over the internet. What lets each device interpret the other's messages?

  1. They use identical processors
  2. They follow shared communication protocols
  3. They have the same amount of memory
  4. They store the same local files
Show answer and explanation

Correct answer: B. They follow shared communication protocols

A protocol defines shared rules for exchanging data. Different devices can communicate if their software follows the relevant rules.

Question reference

Level 4 · Fixed-width representation

Each badge in a collection needs a unique binary code of the same length. The collection grows from 8 badges to 9. What is the minimum code length that still allows a unique code for each badge?

  1. 9 bits
  2. 3 bits
  3. 5 bits
  4. 4 bits
Show answer and explanation

Correct answer: D. 4 bits

Three bits give 2³ = 8 distinct codes. Four bits give 2⁴ = 16 codes, enough for all nine badges.

Question reference

Level 5 · Bias in collected data

A library surveys weekday afternoon visitors to estimate how many people in town would use Saturday hours. What is the main limitation of this approach?

  1. It uses the same question for each visitor
  2. It misses people who cannot visit on weekday afternoons
  3. It records preferences instead of visitor names
  4. It summarizes the responses as a percentage
Show answer and explanation

Correct answer: B. It misses people who cannot visit on weekday afternoons

The collection method leaves out people whose schedules prevent weekday afternoon visits. Those people may have different preferences about Saturday hours.

Question reference

Level 6 · Fault tolerance

A public notice can be served from three independent copies. If one copy becomes unavailable, either remaining copy can still serve the notice. Which design idea makes that possible?

  1. Redundancy
  2. Data compression
  3. Random sampling
  4. Sequential execution
Show answer and explanation

Correct answer: A. Redundancy

Redundancy provides extra components that can continue serving the same purpose when one component becomes unavailable.

Question reference

Level 7 · List operations

Using list indices that start at 1, L begins as [12, 19, 25]. The program runs INSERT(L, 2, 17) followed by REMOVE(L, 3). What is L now?

  1. [12, 19, 17]
  2. [12, 19, 25]
  3. [12, 17, 19]
  4. [12, 17, 25]
Show answer and explanation

Correct answer: D. [12, 17, 25]

INSERT puts 17 at index 2 and shifts 19 to index 3. REMOVE then deletes the 19, leaving [12, 17, 25].

Question reference

Level 8 · Compound conditions

A tool displays a notice when (editing OR reviewing) AND NOT archived is true. Which set of values causes the notice to appear?

  1. editing false, reviewing false, archived false
  2. editing true, reviewing false, archived true
  3. editing false, reviewing true, archived false
  4. editing false, reviewing true, archived true
Show answer and explanation

Correct answer: C. editing false, reviewing true, archived false

Reviewing makes the OR expression true. Archived is false, so NOT archived is also true. Both parts of the AND are therefore true.

Question reference

Level 9 · Remainders and indexing

A program cycles through eight slots numbered 1 through 8 using slot ← (ID MOD 8) + 1. Which slot receives ID 37?

  1. 6
  2. 5
  3. 4
  4. 7
Show answer and explanation

Correct answer: A. 6

Dividing 37 by 8 leaves a remainder of 5. Adding 1 turns that remainder into slot 6.

Question reference

Level 10 · Random selection

A list contains [blue, white, white, green, white]. The program reads the element at index RANDOM(1, 5), where each integer from 1 through 5 is equally likely. What is the probability of reading white?

  1. 2/5
  2. 1/3
  3. 1/5
  4. 3/5
Show answer and explanation

Correct answer: D. 3/5

White occupies three of the five equally likely positions. The probability is 3 out of 5.

Question reference

Level 11 · A loop with a stopping condition

A program starts with n ← 3 and steps ← 0. In REPEAT UNTIL (n ≥ 12), the body adds 4 to n and adds 1 to steps on each pass. What is the final pair (n, steps)?

  1. (11, 2)
  2. (15, 4)
  3. (15, 3)
  4. (12, 3)
Show answer and explanation

Correct answer: C. (15, 3)

The successive values of n are 7, 11, and 15. The condition is true at 15, so the loop ends after three passes.

Question reference

Level 12 · Combining procedure calls

A procedure adjust(a, b) returns b − a when a < b. Otherwise, it returns a. What is the result of adjust(2, adjust(6, 4))?

  1. 6
  2. 4
  3. 2
  4. −2
Show answer and explanation

Correct answer: B. 4

The inner call returns 6 because 6 is greater than 4. The outer call is then adjust(2, 6), which returns 6 − 2 = 4.

Question reference

Level 13 · Choosing a revealing test case

A procedure should return true if a list contains at least two negative numbers. The current version looks only at the first two entries and returns whether both are negative. Which list reveals the error?

  1. [−3, 0, 2]
  2. [−3, −2, 1]
  3. [1, 2, −3]
  4. [1, −2, −3]
Show answer and explanation

Correct answer: D. [1, −2, −3]

The first list has two negative values, so the intended result is true. Its first two entries include only one negative, so the current version returns false.

Question reference

Level 14 · Parallel execution

A program takes 4 seconds to prepare data. Then two independent jobs take 6 seconds and 9 seconds. Once both jobs finish, combining the results takes 2 seconds. How long does the program take if the jobs run at the same time with no extra overhead?

  1. 15 seconds
  2. 12 seconds
  3. 17 seconds
  4. 21 seconds
Show answer and explanation

Correct answer: A. 15 seconds

Preparation takes 4 seconds. Both jobs are done after 9 seconds of parallel work. Combining takes 2 more seconds, for a total of 15 seconds.

Question reference

Level 15 · Tracing list updates

L starts as [5, 2, 6, 1]. A loop visits indices i = 2, 3, and 4 in order. If L[i] < L[i − 1], it immediately replaces L[i] with L[i] + L[i − 1]. What is L after the loop?

  1. [5, 7, 6, 6]
  2. [5, 7, 6, 7]
  3. [5, 7, 13, 14]
  4. [5, 2, 6, 1]
Show answer and explanation

Correct answer: C. [5, 7, 13, 14]

At index 2 the value becomes 7. Index 3 compares 6 with that updated 7 and becomes 13. Index 4 compares 1 with 13 and becomes 14.

Question reference