1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Python

Exercise

while: warming up

The while loop is like a repeated if statement. The code is executed over and over again, as long as the condition is True. Have another look at its recipe.

while condition :
    expression

Can you tell how many printouts the following while loop will do?

x = 1
while x < 4 :
    print(x)
    x = x + 1

Instructions

50 XP

Possible answers