Font size
WorksheetsDomain 2 Practical Application
Total questions: 29
Worksheet time: 27mins
An update loop needs to run and display a message when someone covers a mile. The loop should run for 26 miles. Fill in the blank code with the range necessary to run the loop 26 times, starting with mile 1.
(a)
An update loop needs to run and display a message when someone covers a mile. The loop should run for 14 miles. Fill in the blank code with the range necessary to run the loop 26 times, starting with mile 1.
(a)
Add the punctuation necessary to make the decision logic work for this code:
(a)
A game player is collecting stamps for a game. The player gets rewarded as follows:
1000 points when 10 stamps are collected
500 points when 5 stamps are collected
0 points until 5 stamps are collected
Using this code snippet as a starting point, fill in the blank needed for this decision flow to work.
(a)
A new Python developer wants to know how to skip an iteration of a while loop without stopping the loop completely. Which keyword should be added to the loop, along with a condition, to fill this need?
pass
Examine the following code. Line numbers are for reference only.
Which line number contains a compound condition?
(a)
There is a limit to the number of times the elif keyword can be used within an if/elif/else block.
A nested if statement can contain only one additional if statement.
For loops can contain while loops, and while loops can contain for loops.
A loop is iterating through a list of locations. When the West location is reached, a special message must be printed, and then the loop stops. Fill in the keyword necessary to stop the loop at that point.
(a)
Analyze the following code. Line numbers are for reference only. On which line is there a compound conditional statement?
(a)
Examine the following code:
How many print statements will this code generate?
(a)
A teacher wants to provide early reports on student grades. The criteria for the messages are as follows:
➛A score above 90 is excellent
➛A score above 80 is good
➛All other scores need improvement
Fill in the missing part of this decision flow with the keyword needed for the last bullet point in the list of requirements.
(a)
A code snippet is set up to iterate through a list of locations and print each location. Fill in the keyword that is needed for the type of loop to run.
(a)
Examine the following code that loops through a list of guitars:
The slide guitars are out of stock. Add the keyword necessary to skip the iteration of the loop once it reaches the slide guitar
(a)
A block of code is being built to show messages based on the following logic:
A score above 90 is excellent
A score above 80 is good
All other scores need improvement
Fill in the keyword necessary to finish developing this code block.
(a)
Fill in the missing piece of the code to print a “you won” message when someone’s score exceeds 10000.
(a)
A new Python developer is trying to run this code and is getting a syntax error when running said code.
What needs to change within the code to make the code work?
Change the colon to a curly bracket
Capitalize if
Indent the print statement
Change the colon to a semicolon
A block of code is being built to show messages based on the following logic:
A score above 90 is excellent
A score above 80 is good
All other scores need improvement
Fill in the keyword necessary to finish developing this code block.
(a)
A game player is collecting stamps for a game. The player gets rewarded as follows:
1000 points when 10 stamps are collected
500 points when 5 stamps are collected
0 points until 5 stamps are collected
Using this code snippet as a starting point, fill in the blank needed for this decision flow to work.
(a)
A game needs to update one’s score until the score reaches a certain plateau. The code has been started. Add the keyword needed to have this code fulfill the game's needs.
(a)
A while loop can get caught in an endless loop.
Using drag and drop, match each loop-based keyword with a situation in which the keyword is used.
To stop a loop
break
To skip an iteration of a loop
continue
To serve as a placeholder for code
pass
A loop goes through and prints out the types of guitars in stock. The slide guitars are out of stock. The business owner wants to see a different message in that situation but is not sure what the message should be.
Fill in the blank with a keyword that is used as a placeholder for future code.
(a)
A developer is working on messaging for a game while a player has lives. The message itself runs a fixed number of times. Fill in the keyword necessary to run the correct loops in the correct situations.
(a)
