
AP CSP - Unit Programming (2)

Assessment
•
Quốc Thư
•
Computers
•
8th - 10th Grade
•
27 plays
•
Hard
Student preview

23 questions
Show all answers
1.
FILL IN THE BLANK
2 mins • 5 pts
The following code snippet processes a list of strings with a loop and conditionals:
The code relies on one string procedure, LEN(string), which returns the number of characters in the string.
2.
MULTIPLE CHOICE
2 mins • 5 pts
A movie website lets users create lists of their favorite movies.
When the user first starts, the website runs this code to create an empty list:
favMovies ← []
The user can then insert and remove items from the list.
Here's the code that was executed from one user's session:
3.
MULTIPLE CHOICE
2 mins • 5 pts
The following numbers are displayed by a program:
4 8 12 16
The program code is shown below, but it is missing three values: <COUNTER>, <AMOUNT>, and <STEP>.
Given the displayed output, what must the missing values be?
4.
MULTIPLE CHOICE
2 mins • 5 pts
A program races four avatars against each other: Piceratops, Leafers, Duskpin, and Aqualine.
Here they are lined up at the start line, in that order:
After the first 3 repetitions of each loop, which avatar will be ahead?
5.
MULTIPLE CHOICE
2 mins • 5 pts
A javelin thrower is writing code to track the distance of their throws and how far they are from their target distance.
This is what they have so far:
A friend points out that they can reduce the complexity of their code by using the abstractions of lists and loops.
The programmer decides to "refactor" the code, to rewrite it so that it produces the same output but is structured better.
Which of these is the best refactor of the code?
6.
MULTIPLE CHOICE
2 mins • 5 pts
The two programs below are both intended to display the total number of overtime hours worked, based on a list of logged hours for each day of a week.
Which of these statements best describes these two programs?
7.
MULTIPLE CHOICE
2 mins • 5 pts
A vending machine manufacturer is writing code to determine the optimal prices for their products.
The program below processes a list of costs (in dollars and cents). The goal of the program is to create a new list that contains only the costs that can be paid entirely in quarters.
A line of code is missing, however.
What can replace <MISSING CODE> so that this program will work as expected?
8.
MULTIPLE CHOICE
2 mins • 5 pts
The two procedures below are both intended to return the total number of excess calories eaten in a day based on a list of calories in each meal.
Consider these procedure calls:
excess1 ← calcExcess1([700, 800, 600, 300])
excess2 ← calcExcess2([700, 800, 600, 300])
Which of these statements best describes the difference between the procedure calls?
9.
FILL IN THE BLANK
2 mins • 5 pts
The following code snippet processes a list of strings with a loop and conditional:
The code relies on one string operation, UPPER(string), which returns string in uppercase.
What value will this program display?
10.
MULTIPLE CHOICE
2 mins • 5 pts
Charlotte is writing code to turn sentences into Pig Latin.
This is what she has so far:
A friend points out that she can reduce the complexity of her code by using the abstractions of lists and loops.
Charlotte decides to "refactor" the code, to rewrite it so that it produces the same output but is structured better.
Which of these is the best refactor of the code?
Explore all questions with a free account
Find a similar activity
Create activity tailored to your needs using
Programming Quiz

•
10th Grade
File handling and procedure

•
9th - 12th Grade
AP CSP Exam Review Big Idea 1

•
9th - 12th Grade
AP CS Exam Review

•
9th - 12th Grade
APCSP BJC Unit 4

•
9th - 12th Grade
Understanding Procedures and Functions in Python

•
9th Grade
Unit 4: Exam – Version A

•
9th Grade
3B - AP CSP

•
9th - 12th Grade