NEW
Font size
WorksheetsFor Loop Python_2024
Total questions: 20
Worksheet time: 11mins
Look at the following code, what will it generate
1,2,3,4,5,6,7,8,9,10,11,12
0,1,2,3,4,5,6,7,8,9,10,11,12
1,2,3,4,5,6,7,8,9,10,11,12,13
0,1,2,3,4,5,6,7,8,9,10,11,12,13
What does the following program display?
1,2,3,4
1,2,3,4,5
counter,counter,counter,counter,counter
0,1,2,3,4,5
1,2,3,4
#What is the output?
1,2,3,4,5
0,1,2,3,4
1,2,3,4
5,4,3,2,1
#How many hallos will be printed?
5
None
4
6
#What is the output?
a, b, c, d, e
a, a, a, a, a
0,1,2,3,4
e, d, c, b, a
word= "computer"
for num in range(1,6):
print(word)
for number in range(6):
print(number)
Which of the following programs prints ten lines?
for i in range(10):
print("hi")
for i = 1 to 10:
print("hi")
for i in 1 - 10:
print("hi")
for i from 0 to 9:
print("hi")
What would be the output of the following code:
for i in range(3):
print(i)
1 2 3
i i i i
i i i
0 1 2
What would be the output of the following code:
for i in range(3):
print(5)
0 1 2
3 3 3 3 3
5 5 5
0 1 2 3 4
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
Which of these will allow me to print all numbers from 0 to 4 ?
//0,1,2,3,4
for x in range(4):
print(x)
for x in range(0,4):
print(x)
for x in range(1,5):
print(x)
for x in range(5):
print(y)
What will this code do?
Print Numbers 1-11
Print Numbers 1-10
Print Numbers 2-10
Print Error
For i in range(6):
print('Happy Python')
How many times Happy Python will be printed?
4
5
6
7
What are the syntax errors in this code?
:
Not indented
Both options
What is the output of range(1,10)
0123456789
123456789
1 to 10
012345
How many times does the following program print the word ‘computer’:
word= "computer"
for num in range(2,8):
print(word)
5
6
1
0
For i in range(4):
print('Happy Python')
How many times Happy Python will be printed?
4
5
6
7
