Practice Test 6 - AP Computer Science Principles

20 questions. Answer them in any order, then submit to see your score and every explanation.

  1. Which of the following represents a valid conditional statement structure in the AP Computer Science Principles reference sheet notation?
  2. A programmer has a string variable data assigned the value "user-id:12345". They want to extract the ID number "12345". Assume SUBSTRING(str, start) returns the portion of str from the 1-based index start to the end of the string. The colon is always the 9th character. Which expression will extract the ID?
  3. A programmer is developing an interactive map application. The program waits for the user to click on a specific region of the map. When a click occurs, the program displays detailed information about that region. This style of programming, where the program's execution flow is determined by user actions, is known as:
  4. Which of the following data types requires lossless compression if it is to be compressed at all?
  5. A username is stored in the string variable user. A program needs to display a welcome message, for example, "Welcome, user123!". Which of the following DISPLAY statements will produce the correctly formatted message?
  6. A designer for a new mobile banking application draws a series of sketches that show each screen a user will see. The sketches are arranged in order to illustrate how a user would navigate from the login screen, to their account summary, to transferring funds. This set of sketches is best described as a:
  7. Based on the passage: Distributed genome workflows replicate data across nodes so alignments can resume after failures; parallel workflows focus on coordinated processors within one machine. How does distributed computing enhance fault tolerance?
  8. Based on the provided scenario, identify an error in the banking procedure call sequence when withdrawing funds.​
  9. A student applies iterative binary search on the sorted array (ascending): index 0..9, A=[5, 9, 13, 17, 21, 25, 29, 33, 37, 41]. Target starts as 33 and ends found. Pseudocode uses mid=(low+high)/2. Steps: mid=4 (21)<33 => low=5; mid=7 (33)=target => stop. Refer to the array provided above. What is the position of the target element in the array after applying binary search?
  10. A platform game uses random values to spawn coins, health packs, or enemies in new locations each level. Randomness helps the game feel different because players cannot memorize exact patterns. One playthrough may have many coins nearby, while another has more enemies blocking paths. This uncertainty changes the best strategy from run to run. In the context of the problem, how do random values affect the outcome of this game?
  11. What is a primary trade-off associated with building a fault-tolerant system using redundancy?
  12. A researcher is analyzing a dataset of website user activity, which includes a timestamp for every click. The researcher uses a program to transform the raw timestamps into broader categories like "Morning", "Afternoon", and "Evening". What is the primary benefit of this transformation for generating new knowledge?
  13. A weather simulation program picks a random temperature from 40–95°F and random precipitation type each day. Randomness represents changing conditions that the program cannot know ahead of time. Some days become hot and sunny, while others become cool with rain or snow. The program repeats this for many days to show different possible weekly forecasts. Based on the scenario above, why is randomness important in the context of this simulation?
  14. In a machine learning lab, a student uses the Scikit-learn library (prewritten ML tools) to classify emails as spam or not spam. After from sklearn.neighbors import KNeighborsClassifier, they write model = KNeighborsClassifier(n_neighbors=3) and later model.fit(XTrain, yTrain). Based on the scenario described, which function best trains the classifier on labeled data?
  15. What will be the result of executing this code when num = 15? IF(num MOD 2 = 0) { DISPLAY("Even") } ELSE { IF(num MOD 5 = 0) { DISPLAY("Multiple of 5") } ELSE { DISPLAY("Odd") } }
  16. What is the most likely consequence if this program is used on a broader patient population?
  17. A user is watching a live video stream, but the connection is slow. The video player decides to lower the video quality to ensure the stream can continue without interruption. This decision is based on the current data transfer rate. What network characteristic is being measured to make this adjustment?
  18. What condition would cause the code to follow the 0.00 discount path? // Inputs: isMember, total, isSeasonSale IF isMember IF total >= 100 IF isSeasonSale discount = 0.20 ELSE discount = 0.10 ELSE discount = 0.05 ELSE IF isSeasonSale AND total >= 150 discount = 0.15 ELSE discount = 0.00
  19. Identify the error in the nested conditionals that prevents "Severe Storm" from printing. // Inputs: isThunderstorm, wind IF isThunderstorm IF wind <= 30 PRINT "Severe Storm" ELSE PRINT "Storm" ELSE PRINT "No Alert"
  20. Which of the following describes a situation where citizen science would be a particularly effective approach?

Practice tests