Introduction to Python

Form 4 - Computer

2022-2023

Floor 4 - Computer Room

Mr. Peter, Mr. Lucas

Outline

Outline

Relational Operators

1

If statements

2

The process of if statement

3

Exercises

3

Relational Operators

a = 10
b = 60
c = b / a

print( a + 5 > b )
print( b + a < a * b )
print( a == b / 6 )
print( c != a // b )

What will be printed to the console according to the following program?

If statements

if Condition :

1.

2.

Command1

Tab

Relational Operators

If else statements

else:

Command2

if Condition :

1.

2.

3.

4.

Command1

Tab

Tab

If statements

Check if a person's age qualifies them as an adult.

18

person_age

"Adult"

"Child"

Greater than or Equal to

Otherwise

"成年"

else:

"未成"

if 輸入數 >= 18 :

Tab

Tab

person_age >= 18

"Adult"

"Chlid"

If statements

Check whether a student's grade passes or fails.

60

grade

"Pass"

"Fail"

Greater than or Equal to

Otherwise

"成年"

else:

"未成"

if 輸入數 >= 18 :

Tab

Tab

grade >= 18

"Pass"

"Fail"

F4 - Introduction to Python

By Mr Peter

F4 - Introduction to Python

  • 218