Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit 2 part 2

Total questions: 9

Worksheet time: 45mins

Name
Class
Date
1.
What is displayed as a result of the following code segment?
r = 1
t = 3
r = t + 1
print(r)
a)
1
b)
3
c)
r
d)
4
2.
Which of the following <condition> will make an infinite loop?
j = 0
while <condition>:
j += 3
a)
j = 6
b)
j <= 6
c)
j = 7
d)
j < 7
3.
What is the output?
c = 0
for i in range(10):
if i % 2 == 0:
c += 1
print(c)
a)
10
b)
0
c)
5
d)
6
4.
x = 3 and y = 2. What is the output?
a)
Foxtrot
b)
Hotel
c)
November
d)
Yankee
5.
Fix <condition> so it will print "odd" if the number is odd.
if <condition>:
print("odd")
a)
n%1==0
b)
n%1==1
c)
n%2==0
d)
n%2==1
6.
What ASCII character is represented by binary (base 2) number 01001111?
a)
N
b)
O
c)
P
d)
Q
7.
What is NOT a good use for a constant variable?
a)
Pi as 3.14
b)
Number of days in a week
c)
7% flat tax rate
d)
DOW Stock
8.
The robot starts in the bottom left square facing north. Which will be the final answer?
for i in range(3): MOVE_FORWARD()
MOVE_FORWARD()
ROTATE_RIGHT()
a)
A
b)
B
c)
C
d)
D
9.
What is the condition in this flow chart?
a)
count <- 1
b)
count < 5
c)
count <- count + 1
d)
DISPLAY(count)