wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python if–else Practice 2026

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Python 中用来做判断的关键字是?
(Which keyword is used for decision making in Python?)

a)

for

b)

if

c)

while

d)

else

2.

以下哪个是正确的 if 语法?
(Which one is the correct if syntax?)

a)

if score > 60

b)

if score > 60:

c)

if (score > 60)

d)

if score > 60 then

3.

判断题:Python 的 if 后面一定要有冒号 ( : )。
(True or False: A colon (:) is required after an if statement in Python.)

a)

True

b)

False

4.

以下哪个符号是“等于”判断?
(Which symbol is used to check equality in Python?)

a)

=

b)

==

c)

!=

d)

>=

5.

判断题:else 一定要配合 if 使用。
(True or False: else must always be used with if.)

a)

True

b)

False

6.

以下程序的输出是什么?
(What is the output of the following code?)

a)

Pass

b)

Fail

c)

Error

d)

Nothing

7.

以下程序的输出是什么?
(What is the output of the following code?)

a)

Can vote

b)

Cannot vote

c)

Error

d)

Nothing

8.

哪个条件表示“score 不等于 100”?
(Which condition means “score is not equal to 100”?)

a)

score = 100

b)

score == 100

c)

score != 100

d)

score >= 100

9.

判断题:以下代码是正确的。
(True or False: The following code is correct.)

if score > 60:
print('Pass')

a)

True

b)

False

10.

以下哪一行会造成错误?
(Which line will cause an error?)

a)

if number > 0:

b)

else:

c)

print('Hello')

d)

if score == 50

11.

以下代码缺少哪个关键字?
(What keyword is missing in the code below?)

a)

if

b)

else

c)

for

d)

while

12.

以下程序的输出是什么?
(What is the output of the following code?)

a)

Not zero

b)

Zero

c)

Error

d)

Nothing

13.

判断题:if–else 可以用来判断成绩、年龄和密码。
(True or False: if–else can be used to check scores, ages, and passwords.)

a)

True

b)

False

14.

以下哪个情境最适合使用 if–else?
(Which situation is best suited for using if–else?)

a)


Print a certain sentence 10 times

b)

Determine if it is raining

c)

Store 100 data items

d)

write a function

15.

以下哪一个是条件?
(Which of the following is a condition?)

a)

print('Hi')

b)

score >= 60

c)

input('Name')

d)

int(score)