NEW
Font size
WorksheetsFor and While Loops in Python
Total questions: 16
Worksheet time: 16mins
The program above
prints all the odd numbers between 1 and 20
prints all even numbers between 1 and 20
print all the odd numbers between 1 and 21
prints all the even numbers between 1 and 21
The equivalent of the above for loop using the while syntax would be
The above program prints
Numbers 1 to 10 in reverse order
Numbers 1 to 11 in reverse order
Numbers 1 to 10
Numbers 1 to 11
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
1,2,3,4
What best describes what is printed by the following code?
Prints the numbers 0 through 6
Prints
h
e
l
l
o
w
Prints the phrase "hello world!" 7 times
Prints "hello w" 7 times
What best describes what is printed by the following code?
Prints the numbers 0 through 6
Prints
h
e
l
l
o
w
Prints the phrase "hello world!" 7 times
Prints "hello w" 7 times
What best describes what is printed by the following code?
Prints the numbers 0 through 6
Prints
h
e
l
l
o
w
Prints the phrase "hello world!" 7 times
Prints "hello w" 7 times
In a Python program, what would be the ending value of total in the WHILE LOOP code?
0
5
2
20
In a Python program, what would be the ending value for y in the WHILE LOOP code?
5
51
10
3
5
4
3
2
1
4
3
2
1
0
0
Infinite loop
What is the value of c after the loop finishes?
1
2
3
0
0
4
3
2
1
0
5
4 3 2 1 0
What is the value of nums after the code is executed?
[0, 5, 2]
[0, 2, 4]
[1, 3, 5]
[0, 5]
[2, 3, 4]
5
4
3
2
1
4
3
2
1
0
0
Infinite loop
