NEW
Font size
WorksheetsFor Loop python
Total questions: 19
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)
word= "computer"
for num in range(1,6):
print(word)
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")
Which of the following for loops would print the following numbers?
3
5
7
9
for i in range(3, 10, 2):
print(i)
for i in range(3, 9, 2):
print(i)
for i in range(9):
print(i)
for i in range(3,9):
print(i)
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
numbers = [2, 4, 6, 8]
for number in numbers:
print("hello!")
2 hello! 4 hello! 6 hello! 8 hello!
hello!
2 4 6 8
hello! hello! hello! hello!
Which of the following for loops would print the following numbers?
3
5
7
9
for i in range(3, 10, 2):
print(i)
for i in range(3, 9, 2):
print(i)
for i in range(9):
print(i)
for i in range(3,9):
print(i)
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
