AP Computer Science Principles Practice Worksheets & Answer Key
Print an 8-question AP Computer Science Principles worksheet with a separate answer and explanation section. The selected text questions work without a screen or an account.
Start with 12 original questions on data, code and networks. Selected foundations; check coverage for the full scope.
Version sample-r02 · Original foundation materials · No sign-up
Inside the printable worksheet
8 original questionsSeparate explanationsBrowser print · Version sample-r02
Print the question section first. Keep the answer section separate until you have written your method or reason. Use the linked lessons to review a missed idea, then start a new set in the practice tool.
QUESTION 1 · Reading bit patterns as values and abstractions
A game saves one high score as the byte 01010010. A separate utility later reads those same 8 bits and prints a character. Which statement correctly explains how one stored byte can support both uses?
The programs apply different interpretations to the same bits; the bit sequence alone does not fix what it represents.
Each bit carries its own data type at creation, so a byte stored as a number cannot ever be read as anything else.
Eight bits can be arranged into only 8 different patterns, so each of the two uses is assigned its own stored pattern.
The byte holds two values at once, packing the number and the character into the left and right halves.
Read the answer and explanation
Answer: The programs apply different interpretations to the same bits; the bit sequence alone does not fix what it represents.
Both uses read the identical stored bits, so the explanation cannot come from the storage side. What differs is the reading program: one treats the pattern as an unsigned integer, the other as a character code, and each applies its own decoding rules.
Check each alternative against the scenario: nothing retypes the bits, no second pattern is stored, and no packing is described. A bit sequence alone does not fix its meaning, which is exactly why the same 8 bits can serve both programs.
Review the lesson QUESTION 2 · Evaluate the condition, then choose the branch
A program sets age ← 13 and approved ← false, then runs DISPLAY(NOT (age >= 13) OR approved). What does it display?
true, because age >= 13 is true and one true part is enough for OR
false, because NOT (age >= 13) is false and false OR false is false.
true, because 13 is not strictly greater than 13
true, because NOT applies after the OR is decided and flips the combined result
Read the answer and explanation
Answer: false, because NOT (age >= 13) is false and false OR false is false.
Evaluate the comparison first: 13 >= 13 is true because >= includes the boundary. NOT reverses that to false. Finally false OR false evaluates to false, so the program displays false.
Re-check the grouping to see why every true option fails: NOT binds to the parenthesized comparison only, and OR combines the two already-evaluated parts. The three wrong options correspond to dropping NOT, tightening the boundary, or widening NOT over the whole OR.
Review the lesson QUESTION 3 · Follow a packet from sender to reassembled message
A four-packet video clip is sent from one student’s device to another. The packets leave in order and carry addressing and sequencing information, but they arrive at the receiving device in the order 3, 1, 4, 2. What does the receiving device do to produce the complete clip?
It plays the pieces in arrival order, because that arrival order reflects the routes the packets actually took across the networks.
It asks the sender to resend all four packets along one fixed route so the copies arrive in order.
It restores the original order using each packet’s sequencing information, then reassembles the clip from the ordered pieces.
It waits for the network’s last router to reassemble the clip into one finished stream before delivering it.
Read the answer and explanation
Answer: It restores the original order using each packet’s sequencing information, then reassembles the clip from the ordered pieces.
The receiving device reads each packet’s sequencing information and restores the original order 1, 2, 3, 4 before reassembly. The arrival order 3, 1, 4, 2 reflects the different routes the packets took, not the message’s structure.
The distractor procedures all act at the wrong place or on the wrong evidence: arrival order (routes, not content), resending on one route (unnecessary and contrary to independent paths), or reassembly in a router (ordering information travels for the destination’s use). The stated packet design decides the procedure.
Review the lesson QUESTION 4 · Update lists by tracking positions and length
A program sets vals ← [3, 7, 2, 9, 5] and i ← 2, then runs DISPLAY(vals[i + 2]). What does it display?
7, the element sitting at index i
An index error, because an arithmetic expression cannot be used as a list index
9
5, the element in the fifth slot
Read the answer and explanation
Answer: 9
Compute the index first: i + 2 = 4. Lists are indexed from 1, so vals[4] is the fourth element of [3, 7, 2, 9, 5], which is 9. The index is valid because 4 is between 1 and LENGTH(vals) = 5.
The two numeric alternatives come from skipping the addition or counting slots from 0, and the error option misstates when the index rule applies. All three contradict the 1-based indexing convention, under which the n-th element sits at index n with no offset.
Review the lesson QUESTION 5 · Reading bit patterns as values and abstractions
A sensor package logs the unsigned binary value 101011. What decimal value does it represent?
53
86
43
15
Read the answer and explanation
Answer: 43
Label each place from the right as 1, 2, 4, 8, 16, 32. The 1-bits sit in the 32, 8, 2 and 1 places, so the value is 32 + 8 + 2 + 1 = 43.
Verify by converting back: 43 - 32 = 11, 11 - 8 = 3, 3 - 2 = 1, 1 - 1 = 0, which lights exactly the bits of 101011. Each wrong option shifts, reverses, or replaces the place row, changing which powers of two enter the sum.
Review the lesson QUESTION 6 · Reading bit patterns as values and abstractions
An arcade cabinet stores each score in a fixed 8-bit unsigned integer. A score reaches the largest value the 8 bits can hold, and the player then earns one more point. Which outcome follows from the fixed number of bits?
Eight bits still represent 256 distinct patterns, so the new score of 256 remains representable within them.
The score stays at its maximum and the extra point is dropped without any error or indication appearing.
The stored bit pattern rotates, so the score wraps around to a low value near zero, as some languages handle values beyond their range.
The value 256 is outside the 0-255 range the fixed 8 bits can name, so the score no longer fits: an overflow error occurs.
Read the answer and explanation
Answer: The value 256 is outside the 0-255 range the fixed 8 bits can name, so the score no longer fits: an overflow error occurs.
Eight bits form 2^8 = 256 patterns, and as unsigned integers those patterns name 0 through 2^8 - 1 = 255. The value 256 would need a 257th pattern, so it exceeds what the allotted bits can represent.
That failure is overflow: a computed value exceeds the maximum for the allotted bits. The stem fixes the width at 8 bits, so the options that keep the value playable, by clamping or wrapping, describe program choices outside the stated representation rule.
Review the lesson QUESTION 7 · Evaluate the condition, then choose the branch
A weather panel runs IF(temp > 30) { DISPLAY("Hot") } ELSE { IF(temp > 20) { DISPLAY("Mild") } ELSE { DISPLAY("Cool") } } with temp ← 28. Which output does it produce?
Nothing, because the first condition is false and an IF block runs no statements when its condition is false.
Hot, because 28 is a high temperature
Hot and then Mild, because both comparisons involving 28 can succeed in one pass
Mild
Read the answer and explanation
Answer: Mild
The outer condition temp > 30 is false at 28, so control passes into the ELSE block. The nested condition temp > 20 is true at 28, so the nested IF runs DISPLAY("Mild") and the nested ELSE is skipped.
Trace one decision at a time: the outer IF/ELSE chose the ELSE subtree, and inside it the nested IF/ELSE chose Mild. The failed outer test neither skipped the construct (an ELSE exists) nor allowed a second display.
Review the lesson QUESTION 8 · Evaluate the condition, then choose the branch
A festival app runs IF(points >= 100) { DISPLAY("access") } followed by IF(points > 100) { DISPLAY("bonus") } ELSE { DISPLAY("standard") }, with points ← 100. Which output does the app produce?
access, then standard
access and then bonus
standard, with no access line
access, and nothing else
Read the answer and explanation
Answer: access, then standard
Test each statement in order. 100 >= 100 is true because >= includes the boundary, so access displays. Then 100 > 100 is false because > excludes the boundary, so the second statement takes its ELSE branch and standard displays.
The two operators differ exactly at the boundary value: >= accepts 100, > rejects it. Nothing skips the second statement, so both outputs appear, one from each selection.
Original foundation lessons and 12-question representative sample of a planned 48-question MCQ practice across selected goals; not complete CED coverage..
This fixed sample includes one question per selected skill before additional families. Questions requiring a separate diagram are excluded from this text worksheet. It is an untimed study resource with working space, rather than an official mock examination.
Author-reviewed learning materials. Independent educator review is pending; question difficulty has not been calibrated with learner results. Check coverage and gaps before planning your preparation.
Sources and preparation route
These prompts and explanations are the site's original learning materials. The reference links below support the selected skills; they are not endorsements or official examination questions.