WorksheetsSequence algorithms
Total questions: 18
Worksheet time: 36mins
Danielle is programming a kitty simulator. Part of her code is shown here. What is displayed? when the code runs?
6 9 7
6 7 9
7 9 6
9 7 6
What is displayed when we run this code?
100 100
100 200
200 100
200 200
Imagine we are trying to determine a worker's hourly pay rate, based on how much they make per year. So far we have the code above. Which of the following will calculate the hourly rate correctly?
hourlyRate ← salary % wksInYear % hrsInWeek
hourlyRate ← salary / (wksInYear / hrsInWeek)
hourlyRate ← hrsInWeek / wksInYear / salary
hourlyRate ← salary / hrsInWeek / wksInYear
Suppose we have a number x where
x MOD 10
is the same as x. What is the best description of x?
It is equal to 10
It is greater than 10
It is less than 10
It is a multiple of 10
Suppose that x MOD 10 is 0. What is the best description of x?
x is a multiple of 10, like 10, 20, 30, 40...
x is a factor of 10, like 1, 2, 5, 10.
x is less than 10
x is greater than 10
Suppose that 10 MOD x is 0. What is the best description of x?
x is a multiple of 10, like 10, 20, 30, 40...
x is a factor of 10, like 1, 2, 5, or 10.
x is less than 10
x is greater than 10.
A company can ship cargo on a freight train or a van. They pay $1000 to ship by freight train, no matter how many cars it takes. However, each train car holds 200 boxes, and the train company will only ship full cars. So any extra boxes have to be shipped by van. The van company charges $5 per box they ship. If the number of boxes is represented by the variable numBoxes, which expression correctly calculates the total cost to ship all the boxes?
totalCost ← 1000 + (numBoxes / 200) * 5
totalCost ← 1000 + (numBoxes % 200) * 5
totalCost ← 200 + (numBoxes % 1000) * 5
totalCost ← 200 + (numBoxes / 1000) * 5
totalCost ← 1000 + (numBoxes % 200) * 5
What is result after we run the code segment above? min() is a function that returns the smaller of two numbers; max() is a function that returns the larger of two numbers.
3
5
8
surfaceArea ← 4 * PI * square(radius)
surfaceArea ← 4 * PI * cube(radius)
surfaceArea ← 4 * PI * cube(radius, 2)
surfaceArea ← 4 * PI * pow(radius)
surfaceArea ← 4 * PI * pow(radius, 2)
In this program, how many string variables are there?
1
2
3
4
A programmer is writing a game. Which of the following variables should get a string value?
The score
The time left
The volume level of the sound effects
The player character's name
A programmer is trying to decide whether to represent data as numbers or strings. Which of the following should definitely be represented as a number, not as a string? Pick the best answer.
A ZIP code like 07417
A house number like 123
A number of miles like 14.2 miles
An area code like 201
What is displayed when we run the code above?
BREADPEANUT BUTTER
PEANUT BUTTERBREAD
BREADPEANUT BUTTERBREAD
PEANUT BUTTERBREADPEANUT BUTTER
Suppose we have the code above. We want to display a multiplication problem in the form "x * y = answer." For example, if the user enters 2 and 3, we display: "2 * 3 = 6". Which of the following can we write in <BLANK> to do this correctly?
DISPLAY(x + " * " + y + " = " + (x * y))
DISPLAY(x * y = (x * y))
DISPLAY(x " * " y " = " (x * y))
Which choice is a possible value of randomID after we run the code above?
"button8"
"button52"
"button16"
"button23"
After running the code above, which of the following will display 3?
DISPLAY(a)
DISPLAY("a")
DISPLAY(b)
DISPLAY("b")
html ← "<tag>" + text + "</tag>"
html ← "<" + "tag" + ">" + "text" + "</" + "tag" + ">"
html ← "< + tag + > + text + </ + tag + >"
html ← "<" + tag + ">" + text + "</" + tag + ">"
