WorksheetsPython For
Total questions: 10
Worksheet time: 8mins
Name
Class
Date
1.
What is the syntax for a "for" loop in Python?
a)
for i in range(5):
b)
for i = 1 to 5:
c)
for i in 0..4:
d)
for (i=0; i<5; i++):
2.
Which variable that use to access the current element of a "for" loop?
a)
fruit
b)
x
c)
i
d)
fruits
3.
How many lines that this program prints?
a)
1
b)
2
c)
3
d)
0
4.
What is the output of this program?
a)
3
4
5
6
7
b)
3
4
5
6
c)
1
2
3
4
5
6
7
d)
1
3
5
7
5.
how many lines that this program prints?
a)
2
b)
10
c)
3
d)
4
6.
What is the output of this program?
a)
2
6
9
b)
2
5
8
c)
3
6
9
d)
3
5
7
7.
Which range function give the same list of
range(0, 5, 1)
a)
range(0, 5)
b)
range(5)
c)
range(5, 1)
d)
range(1, 5)
8.
Which range function is given the empty list?
a)
range(5, 10, -1)
b)
range(10, 5, 2)
c)
range(5, 3, -1)
d)
range(1, 2)
9.
How many lines that this program prints? if input 5
(a)
10.
What is the output of this loop? if the input is 5
a)
10
b)
15
c)
21
d)
error
100 %
