AP Computer Science Practice (Interactive)
AP — Computer Science Principles Practice
10 auto-graded practice problems. Select an answer, submit, and review the explanation.
Computational Thinking
A programmer is designing an app that shows the nearest coffee shops on a map. The programmer decides to represent each coffee shop only by its name, latitude, and longitude, ignoring details like opening hours and menu. Which computational thinking practice does this represent?
An algorithm takes a list of 1000 names and checks each name one at a time to find a specific name. If the name is not in the list, how many comparisons will the algorithm perform?
Computing Systems
A computer stores a number in binary as 10110110. What is the decimal equivalent of this binary number?
Which of the following best explains why computers use binary (base-2) representation for data instead of decimal (base-10)?
The hexadecimal number 2F is equivalent to which decimal number?
Algorithms and Programming
Consider the following code segment: FOR i FROM 1 TO 4, DISPLAY(i). What is the output?
A list contains the values [3, 7, 2, 9, 5]. After the following algorithm is applied to the list, what is the value of the last element? SET sum TO 0, FOR EACH element IN list, SET sum TO sum + element, SET lastElement TO sum.
A student writes a procedure called findMax that takes a list of numbers as a parameter and returns the largest value. Which of the following is the most appropriate use of this procedure?
Data Analysis and Networks
Which of the following describes the primary difference between lossy and lossless data compression?
When you type a URL into a browser, the domain name (e.g., example.com) must be converted to an IP address. Which Internet protocol is primarily responsible for this translation?