NEW
Font size
S
M
L
XL
WorksheetsPython_Loop(for) _high level
Total questions: 15
Worksheet time: 2hrs 10mins
Name
Class
Date
1.
To repeat a fixed number of times use a
a)
while loop
b)
for loop
c)
if loop
d)
indentation
2.
To repeat until a particular condition is true use
a)
while loop
b)
for loop
c)
if loop
d)
indentation
3.
The character that must be at the end of the line for if, while, for etc.
a)
:
b)
;
c)
.
d)
,
4.
In a Python program, what would be the starting value in the FOR LOOP code?
a)
100
b)
10
c)
5
d)
20
5.
In a Python program, what would be the starting value in the FOR LOOP code?
a)
25
b)
4
c)
1
d)
0
6.
In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?
a)
15
b)
7
c)
10
d)
1
7.
In a Python program, what would be the ending value in the FOR LOOP code?
a)
14
b)
1
c)
10
d)
15
8.
In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?
a)
15
b)
1
c)
3
d)
5
9.
In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?
a)
-100
b)
1
c)
5
d)
-5
10.
In a Python program, how many iterations(loops) will occur for the FOR LOOP code?
a)
1
b)
10
c)
9
d)
8
11.
In a Python program, how many outputs will occur for the snippet of code?
a)
15
b)
3
c)
6
d)
5
12.
What will print?
a)
1
2
11
2
11
b)
1
2
21
2
21
c)
1
2
3
11
2
3
11
d)
1
2
3
21
2
3
21
13.
Which of the following will print:
a)
for i in range(1, 5):
print(str(i) * 5)
print(str(i) * 5)
b)
for i in range(1, 5):
print("i" * i)
print("i" * i)
c)
for i in range(1, 6):
print("i" * i)
print("i" * i)
d)
for i in range(1, 6):
print(str(i) * i)
print(str(i) * i)
14.
What is the output from this code snippet?
a)
1, 0, 1, 1, 0, 1, 1, 1, 1, 1
b)
0, 1, 1, 0, 1, 1, 0, 1, 1, 0
c)
0, 1, 1, 0, 1
d)
0, 1, 1, 1, 1, 1, 0, 1, 1, 0
15.
How many times does the following program print the word ‘computer’:
word= "computer"
for num in range(1,6):
print(word)
word= "computer"
for num in range(1,6):
print(word)
a)
5
b)
6
c)
1
d)
0
Reset
