
AP CSP Practice Test 1 (2)
Authored by Quốc Thư
Computers
9th - 10th Grade
Used 4+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
What are the possible landing spaces for the robot after running the program segment shown below?
Answer explanation
The robot starts in the center facing to the right. The entire code segment shown is run only once, so we can find the answer by going through all the possibilities separately.
Assuming that the first random number is 0, we will not rotate right at all. The robot can move forward 0, 1, or 2 times, so all the spaces directly in front of the robot’s original position are potential landing spaces.
If the first random number is 1, the robot will rotate right once. The robot can either move forward 0, 1, or 2 times, so the all the spaces to the right of the robot’s original position are potential landing spaces.
(A)This answer misinterprets the rotation command as if the robot could rotate right up to 3 times. The robot can rotate right only once.
(B)This answer interprets the code as if it repeats on a loop. The entire segment is only run once.
(C)This answer misinterprets the rotation command as if the robot could rotate right up to 2 times. It can rotate right only once.
2.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
The two algorithms shown below, Algorithm A and Algorithm B, are intended to calculate average.
Algorithm A
Step 1: Set sum equal to 0.
sum ← 0
Step 2: Set count = 1.
count ← 1
Step 3: Add list[count] to sum.
sum ← sum + list[count]
Step 4: Add 1 to count.
Step 5: Repeat steps 3 and 4 until count is equal to LENGTH(list).
Step 6: Set ave to sum divided by count.
ave ← sum / count
Step 7: Return step 6.
Algorithm B
Step 1: Set sum equal to 0.
sum ← 0
Step 2: Set count = 1.
count ← 1
Step 3: Add list[count] to sum.
sum ← sum + list[count]
Step 4: Add 1 to count.
Step 5: Set ave to sum divided by count.
ave ← sum / count
Step 6: Repeat steps 3, 4, and 5 until count is equal to LENGTH(list).
Step 7: Return the last value calculated in step 5.
Which algorithm calculates average correctly?
Algorithm A calculates average in all cases, while Algorithm B does not.
Algorithm B calculates average in all cases, while Algorithm A does not..
(C)Neither Algorithm A nor Algorithm B calculates average correctly.
Both Algorithm A and Algorithm calculate average correctly, but Algorithm A is more efficient.
Answer explanation
Algorithm A has a variable “sum” initialized to zero and a variable “count” initialized to 1. The algorithm uses count to identify each value in the list and adds them to the sum. At the end, sum is the sum of all the values in the list and count is the total number of values in the list. Taking sum and dividing by count gives the correct average.
Algorithm B has a variable “sum” initialized to zero and a variable “count” initialized to 1. The algorithm uses count to identify each value in the list and adds them to the sum. Each time a number is added to sum and increases the count, the algorithm calculates the average of all the numbers added to sum so far. Although calculating the average at each step takes more time and is therefore less efficient, it does the math correctly. Algorithm B gives correct final values for sum, count, and average.
(A)Algorithm A does calculate the average, but Algorithm B does as well.
(B)Algorithm B does calculate the average, but Algorithm A does as well.
(C)Both Algorithm A and Algorithm B calculate the average correctly.
3.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
Why does program code have to be run through a compiler?
Program code is write-only until it is run through a compiler.
Program code must be translated into a language the computer understands.
Program code must be debugged by the compiler before it can ever run
It doesn’t, as the new program could be run directly from the code.
Answer explanation
A computer can understand only low-level machine code. The problems with machine code are that it is hard for humans to understand and is hard to debug. Upper-level languages with abstractions are easier to code and easier to debug, but the computer cannot understand these languages. Any upper-level language will first need to be translated to the lower-level language that computers can understand.
(A)The compiler translates the upper-level language to machine language.
(C)Programs do not need to be checked for errors (but it is nice when this happens).
(D)All programs need to be translated to machine code.
4.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
The procedure findAverage is intended to return the average number in the list numbers. The procedure does not work as intended for all test cases.
Which of the following test cases will return the correct average using the above procedure?
numbers[1, 1, 35, 6]
numbers[0, 1, 35, 6]
numbers[11, 35, 6]
numbers[3, 5, 11, 6]
Answer explanation
When finding the total in a data structure, the variable needs to be set to 0. In this example, sum is set to the first element in the data structure. The error is this algorithm is counting the first number in the data structure twice. The reason why test case (B) did not have an error is because the first number in the data structure is 0. If 0 is counted twice, it will not result in an error.
(A)The first 1 in the data structure is counted twice.
(C)The first 11 in the data structure is counted twice
(D)The first 3 in the data structure is counted twice.
5.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
Which of the following is NOT an example of using citizen science as a possible solution?
The behavior of fireflies during the summer months
The behavior of the mysterious and wonderful jellyfish on the beach or water
Collecting recordings using ultrasonic microphones and sonograms of bats
Calculating PSAT scores for a school district
Answer explanation
Citizen science is a practice where data are collected either completely or in part by everyday people. This would not work for (C) because everyday people do not know much about using ultrasonic microphones or sonograms.
(A)This is an example of citizen science because people can report their observations of fireflies during summer months.
(B)This is an example of citizen science because people can report their observations of jellyfish.
(D)This is an example of citizen science because people can report their PSAT scores, which can be compared to other scores in the given county.
6.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
A web browser is selling its information cookies to third-party marketing companies. These companies are profiling users and selling the sorted data to targeted advertisers.
The web browser is debating adding a setting called Do Not Track. Once enabled, this setting would send a Do Not Track signal to the websites you visit, informing them that you do not give them permission to collect or share your personal information for behavioral advertising, price discrimination, or for any other purpose.
This setting would stop data brokers from legally selling your personal information from the sites you visit.
Which of the following is the most likely data privacy concern for the original browser?
Information collected about your personal preferences and private activities might be used to brand you as members of a particular group.
Cookies are used to acquire users’ private encryption keys.
Cookies are text files that keep track of such things as website visits and activity on that website.
Cookies are responsible for spam and create pop-up advertisements.
Answer explanation
Knowledge of a user’s personal preferences and private activities might eventually be used to brand each of us as members of a particular group. A person might be labeled as a political activist, which could limit job opportunities.
(B)Cookies are text files that record activity and preferences when visiting websites. They do not store encryption keys or contain viruses.
(C)Cookies could be used to store a shopping cart of unbought items or suggest items that might interest the user on future visits which can enhance your experience.
(D)Advertisers can use cookies to track which pop-up ads you have seen. However, cookies have nothing to do with the advertisement in the first place.
7.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
Which of the following is least likely to receive targeted advertisements?
Individuals using the web browser without the Do Not Track option
Users who visit only websites with a digital certificate that block targeted advertisements
Users with strong passwords and multifactor authentication
Individuals using the web browser with the Do Not Track setting engaged
Answer explanation
If the Do Not Track setting is engaged, it will prevent data sales of your information. Without this data, advertisers cannot target users based on their preferences.
(A)If a web browser does not have the Do Not Track option, its users will very likely be tracked and then receive targeted advertisements.
(B)Digital certificates indicate that the website will exchange data securely over the internet using a public key certificate.
(C)Strong passwords and multifactor authentication keep passwords secure. Targeted advertising does not use or need passwords to categorize users for interest in products.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?