Skip to main content

AP Computer Science Principles Unit 3 practice questions

Try 10 multiple-choice questions from Unit 3 here. Pick an answer to see why it's right or wrong, then take the timed test above for a full AP-style set.

  1. Question 1

    A developer is designing a contact management system. Which question is most important to ask to determine if a phone number should be stored as a string or a number?

    Will the phone numbers be used in any mathematical calculations?

    Will the phone numbers be displayed on a mobile device screen?

    Will the phone numbers be entered by a user or an administrator?

    Will the phone numbers be associated with a specific contact name?

    Show answer

    Answer: (A)

    Investigating the need for arithmetic operations is critical because numeric types are for values used in calculations, whereas phone numbers are identifiers that may contain leading zeros or formatting characters better suited for strings.

  2. Question 2

    A school database tracks student grades. Which requirement would necessitate changing a variable's data type from an integer to a floating-point number?

    The need to record partial credit scores like 85.585.5 on assignments

    The need to store scores that exceed the value of 100 on exams

    The need to calculate the average of multiple integer scores for a final grade

    The need to display the letter grade corresponding to the numerical score

    Show answer

    Answer: (A)

    Investigating the precision requirements reveals that integers cannot represent fractional values, necessitating a floating-point variable to store decimal data.

  3. Question 3

    A program manages inventory for a grocery store. Which feature of the inventory data best justifies using a list variable rather than multiple individual variables?

    The inventory contains a large, changing number of item names

    The inventory includes items with long, complex descriptive names

    The inventory requires storing the price for a single specific item

    The inventory data must be converted to text for display purposes

    Show answer

    Answer: (A)

    Investigating the data volume and structure reveals that a dynamic collection of items is best represented by a list, which can grow and shrink, unlike a fixed set of individual variables.

  4. Question 4

    A developer is programming a smart light system. Which investigative finding suggests that a Boolean variable is insufficient to represent the light's state?

    The light supports brightness levels ranging from 00 to 100100 percent

    The light can be toggled between an on state and an off state

    The light is controlled by a mobile application over the network

    The light has a scheduled timer to turn off automatically at night

    Show answer

    Answer: (A)

    Investigating the device capabilities reveals a range of values (0-100), which requires a numeric type, whereas a Boolean can only represent two states (true/false).

  5. Question 5

    A team is reviewing code for a weather app. Which observation about the variable t best indicates a need to rename it to currentTemp for maintainability?

    The variable t is ambiguous and does not clearly describe its value

    The variable t is used in multiple different calculation functions

    The variable t stores a floating-point number rather than an integer

    The variable t is assigned a new value every time the sensor updates

    Show answer

    Answer: (A)

    Investigating code quality focuses on readability; t is an arbitrary letter, whereas currentTemp provides semantic meaning, making the code easier to understand and maintain.

  6. Question 6

    A developer investigates data requirements for storing US zip codes. Which characteristic of zip codes makes the string data type more appropriate than an integer?

    Some zip codes begin with a leading zero that must be preserved

    Some zip codes represent regions with very large population counts

    Some zip codes are used in calculations to determine shipping costs

    Some zip codes are entered by users through a digital keypad interface

    Show answer

    Answer: (A)

    Investigating the data format reveals that numeric types typically strip leading zeros (e.g., 02138 becomes 2138), making a string necessary to preserve the exact sequence.

  7. Question 7

    A program collects user input for age. Which planned usage of this data requires ensuring the variable is stored as or converted to a numeric type?

    Calculating the user's birth year by subtracting age from the current year

    Displaying the user's age alongside their name on a profile page

    Storing the user's age in a database field labeled for text data

    Validating that the user has entered a value into the age field

    Show answer

    Answer: (A)

    Investigating the task reveals a mathematical operation (subtraction), which requires the operand to be a numeric type rather than a string.

  8. Question 8

    A music app developer needs to store a user's playlist. Which aspect of the data most strongly suggests using a list variable instead of a string variable?

    The playlist consists of an ordered sequence of multiple song titles

    The playlist contains song titles that include numeric characters

    The playlist requires a variable name that indicates its content

    The playlist is displayed to the user in a specific font style

    Show answer

    Answer: (A)

    Investigating the data structure identifies it as a collection of distinct items, which is the definition of a list, rather than a single text value.

  9. Question 9

    A warehouse system uses product IDs like "A1-45". Why is it necessary to investigate the format of these IDs before assigning a data type?

    The presence of letters and hyphens requires a string representation

    The presence of numbers requires an integer or float representation

    The length of the ID string determines whether a fixed-length or variable-length string representation is needed

    The hyphen character requires a special data type that can store punctuation separately from alphanumeric characters

    Show answer

    Answer: (A)

    Investigating the content reveals non-numeric characters (letters, hyphens), which cannot be stored in integer or float variables, necessitating a string.

  10. Question 10

    A survey asks "Do you own a car?". Which property of the expected response best supports using a Boolean variable to store the answer?

    The response can only be one of two possible values: true or false

    The response might include the make and model of the car owned

    The response is text that needs to be capitalized for display

    The response will be aggregated to calculate a total count

    Show answer

    Answer: (A)

    Investigating the domain of possible answers reveals a binary state (Yes/No), which maps perfectly to the Boolean data type.

What's on the AP Computer Science Principles Unit 3 practice test

The standard version takes about 64 minutes and follows the timing and directions of the AP exam, sized to one unit:

  • 20 Multiple Choice Questions (34 minutes)
  • 1 FRQ – Written Response 2 (30 minutes)

Questions are drawn from 4403 multiple-choice questions and 120 FRQs written for Unit 3, Algorithms and Programming.

Practice AP Computer Science Principles Unit 3 FRQs

Answer the unit's free-response questions one at a time and get a score on every part.

Review Unit 3 before you start

Other AP Computer Science Principles unit tests