Lesson 3/6 · Graduation exam preparationNot startedhigh School~90 min
The while loop
A loop that runs while a condition holds: counting down, skipping numbers, reading repeatedly until an end value, and handling bad input.
After this lesson you'll be able to:
- Write a `while` loop with and without a counter
- End a loop with `break` and skip a step with `continue`
- Avoid an infinite loop
Theory (PDF)
The theory for this lesson is being prepared.
Examples to try
Your code runs only in this browser, in an isolated environment with no access to the internet or your account.
Examples for this lesson are being prepared.
Exercises
Start the exercises- Write a programTime in secondsElementary20 XP
- Write a programGuess the wordBasic10 XP
- Write a programNumbers without 3, 7 and 14Basic10 XP
- Write a programEven numbers up to a limitBasic10 XP
- Write a programCharacters and their positionsBasic10 XP
- Write a programCounting down to 5Basic10 XP
- Write a programOdd numbers except 17Basic10 XP
- Algorithmic problemThe Collatz sequenceElementaryOptional20 XP
- Algorithmic problemTo binaryElementaryOptional20 XP