WorksheetsPython L6 Condition If else
Total questions: 12
Worksheet time: 9mins
What is the main purpose of an if-else statement?
if-else 的主要目的是什么?
To repeat code many times
多次重复代码
To make decisions based on conditions
根据条件做出决策
To print messages randomly
随机打印消息
To store data in lists
将数据存储在列表中
What symbol is used for “equal to” in Python conditions?
在 Python 条件判断中,表示“等于”的符号是什么?
=
==
:=
=>
Which operator means “not equal to”?
哪个运算符表示“不等于”?
≠
=!
!=
=>
What happens if the condition in an if statement is False?
如果 `if` 语句中的条件为 False,会发生什么?
The code inside the if block still runs
if 代码块中的代码仍然会执行。
The else block runs instead (if provided)
else 代码块会改为执行。
Python gives an error
Python 出现代码错误
Nothing happens at all
什么事也没发生
What does the % (modulo) operator do?
% 运算符有什么作用?
Divides two numbers
将两个数相除
Gives the remainder after division
返回除法运算后的余数
Multiplies two numbers
将两个数相乘
Finds the square root
计算平方根
Which of these is a correct if-elif-else structure?
以下哪一个是正确的 if-elif-else 结构?
if → else if → else
if → elif → else
when → elif → stop
if → and → or → else
When do you use nested if-else?
什么时候使用nested if-else?
When one decision depends on another
当一个决定取决于另一个决定时
To make the code shorter
为了缩短代码
To print many lines at once
一次打印多行
To stop the program
停止程序
What happens in an if-elif-else chain when one condition is True?
在 if-elif-else 链中,当其中一个条件为 True 时,会发生什么?
Python checks all the rest
Python 检查其余所有内容。
Python skips the remaining conditions
Python 会跳过剩余的条件。
Python runs all True statement
Python 执行所有为真的代码。
Python restarts the program
Python 重启程序
Which of these is the correct BMI formula?
以下哪一个是正确的 BMI 公式?
BMI = height / (weight * weight)
BMI = weight / (height * height)
BMI = (height + weight) / 2
BMI = weight * height
解释这一行的含义:
Explain what this line means:
if number % 2 == 0:
Why is indentation important in if-else statements?
为什么在 if-else 语句中 Indentation 很重要?
It has no effect on code execution in if-else statements.
它对 if-else 语句中的代码执行没有影响。
It shows which lines belong to the if or else block; without it, Python gives an error.
它显示出哪些代码行属于 if 或 else 代码块;如果没有它,Python 会报代码错误。
It is only necessary for loops, not if-else statements.
这仅适用于循环,而不适用于 if-else 语句。
It is used to increase the speed of code execution in if-else statements.
它用于提高 if-else 语句中代码的执行速度。
What will this code print if the user enters age = 16?
如果用户输入 age = 16,这段代码会输出什么?
