while <condition>:
<loop statements>
While loops
- Conditional iteration tests a condition to determine if a loop should continue
- Called continuation condition
Examples
= 10
x while x > 0:
print(x)
= x - 1 x
10
9
8
7
6
5
4
3
2
1
= 0
count while (count < 10):
# Point A
print ("Olá...", count)
= count + 1
count # Point B
# Point C
Consider the following affirmations and say if they are right or wrong:
count < 10
is alwaysTrue
at point C.count < 10
is alwaysFalse
at point B.count < 10
is alwaysTrue
at point A.count < 10
is alwaysFalse
at point C.count < 10
is alwaysTrue
at point B.