UNIT 02 · TOPIC 13
while Loop
A while loop repeats a block as long as its condition remains true.
The idea
while Loop, simply explained
A while loop repeats a block as long as its condition remains true.
01
See the big picture
How the idea flows
Read the diagram as a simple path: begin with a problem, use the Python idea, then verify the result.
02
Everyday connection
Real-life example
↗
A lift keeps moving while it has not reached the selected floor.
03
Learn by doing
Python code example
PYTHONExample
floor = 1
while floor <= 3:
print(floor)
floor += 1Expected result
1
2
3Try it: Change one value in the code, predict what will happen, then run it and compare your answer.
04
Keep this in mind
Key takeaways
- A while loop repeats a block as long as its condition remains true.
- Think of a real problem where while loop could save time or organize information.
- Test small changes and read the result carefully before moving to a bigger program.
Quick self-check
Can you explain it in your own words?
What is the main idea of while Loop?
A while loop repeats a block as long as its condition remains true.
Where could you see this idea in everyday life?
A lift keeps moving while it has not reached the selected floor.
