wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Domain 2 Practical Application

Total questions: 29

Worksheet time: 27mins

Name
Class
Date
1.

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)  

2.

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)  

3.

Add the punctuation necessary to make the decision logic work for this code:

(a)  

4.

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)  

5.

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?

a)
break
b)
exit
c)
continue
d)

pass

6.

Examine the following code. Line numbers are for reference only.

Which line number contains a compound condition?

(a)  

7.

There is a limit to the number of times the elif keyword can be used within an if/elif/else block.

a)
You can only use two elif statements.
b)
The elif keyword can be used once only.
c)
There is no limit to the number of elif statements.
d)
There is a maximum of five elif statements allowed.
8.

A nested if statement can contain only one additional if statement.

a)
True
b)
False
c)
Nested if statements are not allowed.
d)
A nested if statement can contain multiple if statements.
9.

For loops can contain while loops, and while loops can contain for loops.

a)
True
b)
False
c)
Only while loops can contain for loops.
d)
Only for loops can contain while loops.
10.

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)  

11.

Analyze the following code. Line numbers are for reference only. On which line is there a compound conditional statement?

(a)  

12.

Examine the following code:

How many print statements will this code generate?

(a)  

13.

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)  

14.

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)  

15.

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)  

16.

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)  

17.

Fill in the missing piece of the code to print a “you won” message when someone’s score exceeds 10000.

(a)  

18.

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?

a)

Change the colon to a curly bracket

b)

Capitalize if

c)

Indent the print statement

d)

Change the colon to a semicolon

19.

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)  

20.

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)  

21.

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)  

22.

A while loop can get caught in an endless loop.

a)
True
b)
Loops cannot end unexpectedly
c)
Only in specific cases
d)
False
23.
The character that must be at the end of the line for if, while, for etc.
a)
:
b)
;
c)
.
d)
,
24.
To repeat a fixed number of times use a
a)
while loop
b)
for loop
c)
if loop
d)
indentation
25.
Consider the loop control structure in programming. Which term describes a loop that continues repeating without a terminating (ending) condition?
a)
Conditional Loop
b)
Unlimited Loop
c)
Sequence Loop
d)
Infinite Loop
26.
Loop executed a fixed number of times with a built-in-counter (creating a counter variable is unnecessary).
a)
While loop
b)
For loop
c)
Repeat loop
d)
If...else
27.

Using drag and drop, match each loop-based keyword with a situation in which the keyword is used.

a)

To stop a loop

1.

break

b)

To skip an iteration of a loop

2.

continue

c)

To serve as a placeholder for code

3.

pass

28.

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)  

29.

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)