Introduction to Python
Form 4 - Computer
2023-2024
Floor 4 - Computer Room
Mr. Peter
Outline
Outline
If Statement
![](https://s3.amazonaws.com/media-p.slid.es/uploads/2214875/images/9811262/pasted-from-clipboard.png)
1
While Loop
2
While Loop Statement
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1490014/images/9343467/pasted-from-clipboard.png)
1.
2.
Tab
while Condition :
Command1
![](https://s3.amazonaws.com/media-p.slid.es/uploads/2214875/images/10437733/pasted-from-clipboard.png)
While Loop Statement
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1490014/images/9343467/pasted-from-clipboard.png)
i = 1
while i <= 10:
print(i)
i = i + 1
While Loop from 1 to 10
IF statement - Odd or Even
Odd or Even
Write a Python Program to check an input value from user, if the number input from user is odd, print "Odd". Otherwise, print "Even"
Example
n = int( input( "Please input a positive integer: " ) )
![](https://s3.amazonaws.com/media-p.slid.es/uploads/2214875/images/11181182/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/2214875/images/11181183/pasted-from-clipboard.png)
Save the file as "XX_YYYY_Revision01.py"
While loop statement - Revision02
Right Triangle
Write a program that asks the user to enter a positive integer n, and then prints a right triangle consisting of n rows of asterisks.
![](https://srleng.com/view-only/2022-2023/3rd Term/python/ex13.gif)
Example
n = int( input( "Please input a positive integer: " ) )
Save the file as "XX_YYYY_Revision02.py"
While loop statement - Revision03
Inverse Right Tangle
Write a program that asks the user to enter a positive integer n, and then prints a right triangle consisting of n rows of asterisks.
Example
n = int( input( "Please input a positive integer: " ) )
![](https://srleng.com/view-only/2022-2023/3rd Term/python/ex13_1.gif)
Save the file as "XX_YYYY_Revision03.py"
Python - Test Revision
By Mr Peter
Python - Test Revision
- 214