Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python L6 Condition If else

Total questions: 12

Worksheet time: 9mins

Name
Class
Date
1.

What is the main purpose of an if-else statement?

if-else 的主要目的是什么?

a)

To repeat code many times

多次重复代码

b)

To make decisions based on conditions

根据条件做出决策

c)

To print messages randomly

随机打印消息

d)

To store data in lists

将数据存储在列表中

2.

What symbol is used for “equal to” in Python conditions?

在 Python 条件判断中,表示“等于”的符号是什么?

a)

=

b)

==

c)

:=

d)

=>

3.

Which operator means “not equal to”?

哪个运算符表示“不等于”?

a)

≠

b)

=!

c)

!=

d)

=>

4.

What happens if the condition in an if statement is False?

如果 `if` 语句中的条件为 False,会发生什么?

a)

The code inside the if block still runs

if 代码块中的代码仍然会执行。

b)

The else block runs instead (if provided)

else 代码块会改为执行。

c)

Python gives an error

Python 出现代码错误

d)

Nothing happens at all

什么事也没发生

5.

What does the % (modulo) operator do?

% 运算符有什么作用?

a)

Divides two numbers

将两个数相除

b)

Gives the remainder after division

返回除法运算后的余数

c)

Multiplies two numbers

将两个数相乘

d)

Finds the square root

计算平方根

6.

Which of these is a correct if-elif-else structure?
以下哪一个是正确的 if-elif-else 结构?

a)

if → else if → else

b)

if → elif → else

c)

when → elif → stop

d)

if → and → or → else

7.

When do you use nested if-else?

什么时候使用nested if-else?

a)

When one decision depends on another

当一个决定取决于另一个决定时

b)

To make the code shorter

为了缩短代码

c)

To print many lines at once

一次打印多行

d)

To stop the program

停止程序

8.

What happens in an if-elif-else chain when one condition is True?

在 if-elif-else 链中,当其中一个条件为 True 时,会发生什么?

a)

Python checks all the rest

Python 检查其余所有内容。

b)

Python skips the remaining conditions

Python 会跳过剩余的条件。

c)

Python runs all True statement
Python 执行所有为真的代码。

d)

Python restarts the program
Python 重启程序

9.

Which of these is the correct BMI formula?

以下哪一个是正确的 BMI 公式?

a)

BMI = height / (weight * weight)

b)

BMI = weight / (height * height)

c)

BMI = (height + weight) / 2

d)

BMI = weight * height

10.

解释这一行的含义:
Explain what this line means: if number % 2 == 0:

4 lines
11.

Why is indentation important in if-else statements?

为什么在 if-else 语句中 Indentation 很重要?

a)

It has no effect on code execution in if-else statements.

它对 if-else 语句中的代码执行没有影响。

b)

It shows which lines belong to the if or else block; without it, Python gives an error.

它显示出哪些代码行属于 if 或 else 代码块;如果没有它,Python 会报代码错误。

c)

It is only necessary for loops, not if-else statements.

这仅适用于循环,而不适用于 if-else 语句。

d)

It is used to increase the speed of code execution in if-else statements.

它用于提高 if-else 语句中代码的执行速度。

12.

What will this code print if the user enters age = 16?

如果用户输入 age = 16,这段代码会输出什么?

a)
Adult ticket is RM12
b)
Teen ticket is RM7
c)
Senior ticket is RM10
d)
Child ticket is RM5