Predict Python 如果/elif/else 输出
预测输出 入门
题目
什么做 这个 Python code print?
代码
n = 0
if n > 0:
print("positive")
elif n < 0:
print("negative")
else:
print("zero")
提示
0 是 neither greater than 0 nor 更少 than 0.
解释
n is 0. The first condition n > 0 is false. The second condition n < 0 is also false. So the else branch runs and prints: zero
相关资源
相关课程
- 条件 and 循环
学习如何 Python 如果/elif/else 条件工作.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。