Floor 4 - Computer Room
Santa Rosa de Lima English Secondary School
聖羅撒英文中學
Colégio de Santa Rosa de Lima - Secção Inglesa
1.
Review the concept of While Loop in Python
2.
Focusing on the syntax of While Statement
3.
Define while loop statement for requirements
1.
2.
Tab
while Condition :
Command1
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1
True
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1
True
1
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1
True
1
2
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1
True
1
2
True
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1
True
1
2
True
2
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1
True
1
2
True
2
2
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1
True
1
2
True
2
3
False
1.
2.
while i < 3 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
i
_______
_______
_______
_______
_______
_______
i < 3
_______
_______
_______
_______
_______
_______
0
Output
_______
_______
_______
_______
_______
_______
True
0
1
True
1
2
True
2
3
False
End
End
End
End
End
End
End
i = 2
while i <= 5:
print( i )
i = i + 1
i = 1
while i < 3:
print( i )
i = i + 2
i = 4
while i != 0:
print( i )
i = i - 2
i = 1
while i < 1 or i > 1:
print( i )
i = i - 2
increment = int( input( 'Enter a positive increment value: ' ) )
1
2
3
4
increment = int( input( 'Enter a positive increment value: ' ) )
1
2
3
4
increment = int( input( 'Enter a positive increment value: ' ) )
1
2
3
4
steps = int( input( 'Enter a positive increment/decrement value: ' ) )
1
2
3
4
steps = int( input( 'Enter a positive increment/decrement value: ' ) )
1
2
3
4
steps = int( input( 'Enter a positive increment/decrement value: ' ) )
1
2
3
4