Introduction to Python

Form 4 - Computer

2023-2024

Floor 4 - Computer Room

Mr. Peter

Outline

Outline

If Statement

1

While Loop

2

While Loop Statement

1.

2.

Tab

while Condition :

Command1

While Loop Statement

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: " ) )

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.

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: " ) )

Save the file as "XX_YYYY_Revision03.py"

Python - Test Revision

By Mr Peter

Python - Test Revision

  • 214