WorksheetsCode.org APCSP Unit 6 Review
Total questions: 29
Worksheet time: 17mins
Which of the following images is the most likely outcome of the drawing?
What is a possible output when the following code segment executes? The ending position of the turtle is shown in each diagram. The starting position is shown as a white triangle in cases where the turtle starts and ends in different locations.
Which of the following is true about while loops ?
While loops terminate after a fixed number of loops that is pre-determined
While loops terminate after a fixed number of loops that is determined after the loop executes once.
While loops run as long as a given boolean condition is true.
While loops run as long as a given boolean condition is false.
While loops are known as "forever loops" and never stop until the program is halted by the user.
Answer
4
7
9
10
ab
2
3
4
5
6
0
1
2
8
Error. Index 3 does not exist.
What will happen when this code runs?
it will print each fruit and the price on a new line
It will print all the fruits and prices at once
It will print "fruit cost price"
It will change the fruit list to be the price list
What goes in the part that's blacked out
i < foot.length
i < fruit
i < fruits
i < fruits.length
What goes in the part that's blacked out
var i = 0
i = fruit
i < fruits.length
i = 0
What does this code do?
prints the index + 1 number and the name of the pet for each pet in the favoritePets list
prints each pet
prints the number of the pet
prints the index number and the name of the pet
What is created at the end of this loop?
Nothing happens
All the animals are printed out
Each animal is printed out in the filtered animals list
Animal words that are greater than 5 letters are put into a filtered list
If the animal whose length of their name is greater than 5 are put into a list, what should that list look like at the beginning of the code?
var animalsFiltered = ['dog', 'cat', 'pig]
var animalsFiltered = []
animalsFiltered = ['dog', 'cat', 'pig]
animalsFiltered = []
What does this code do?
Finds the maximum price
Prints each price
Does nothing
Finds the minimum price
What would you change to find the max price?
if price > maxPrice
if price<maxPrice
if price == 0
if maxPrice = minPrice
What does this do?
Goes through a state list and checks the year of the state.
Goes through a state list and checks the name of the state
Adds the name of the state to a new list
Adds the year of the state to the new list
What should you do here?
state = statesList[i]
year= yearList[i]
state = state[i]
year= year[i]
What does this do?
It filters through the student GradeList
it looks for student grades that are 11
it appends the student name, grade, and age to an empty list
it looks for the youngest student
What should go in the blacked out part?
(a)
Why is this block of code there?
creates the filtered lists
sets the variables to 0
makes the lists empty when you first run the function
makes the lists show on the screen
What should be in this part?
appendItem(filteredStudentNameList, studentNameList[i])
appendItem(filteredStudentAgeList, studentAgeList[i])
appendItem(filteredList[i])
studentGradeList[i] = 0
You want the index to be a random number in the list. What should go in the blacked out part?
fruitList.length - 1
fruitList.length
index.length - 1
index.length
What code is blacked out?
setText("fruitLabel", "text", myList[index]);
appendItem(myList, "peach");
updateScreen();
index = 0;
What should go in the part that is blacked out?
"banana"
fruitList
"fruitList"[index+1]
fruitList[index]
When you click the left button to go down 1 on the index, what do you want to check on first? (2 answers)
if you are at the beginning of the list
if the index is greater than 0
if the index is at the end of the list
if the index is less than the length - 1
When you click the right button to go up 1 on the index, what do you want to check on first? (2 answers)
if you are at the beginning of the list
if the index is greater than 0
if the index is at the end of the list
if the index is less than the length - 1
What is the missing code?
(a)
What code is missing?
myList[index]
index
"pear"
myList[0]
