Complete the code to print numbers from 1 to 5 using a while loop.
count = 1 while count [1] 5: print(count) count += 1
The condition count <= 5 ensures the loop runs while count is 1 through 5.
Complete the code to count down from 10 to 1 using a while loop.
num = 10 while num [1] 0: print(num) num -= 1
The condition num > 0 runs the loop while num is greater than zero, counting down to 1.
Fix the error in the code to print even numbers from 2 to 10 using a while loop.
i = 2 while i [1] 10: print(i) i += 2
The condition i <= 10 ensures the loop includes 10 in the output.
Fill both blanks to create a while loop that prints numbers from 3 to 7.
num = 3 while num [1] 7: print(num) num [2] 1
The loop runs while num <= 7 and increases num by 1 each time with num += 1.
Fill all three blanks to create a while loop that prints odd numbers from 1 to 9.
n = 1 while n [1] 9: print(n) n [2] [3]
The loop runs while n <= 9, and increases n by 2 each time with n += 2 to print odd numbers.