# 分支语的几本书写
age = 15
if age < 18:
print("未成年人不能进出!") #tab输入四个空格
if 1 == 1 :
print("等于1")
else :
print("不等于1")
b = 1==1
print(b)
print(1 == 1.0)
print("abc".lower() == "ABC".lower())
print(" abc".strip() == "abc") #删除空格
print(str(1) == "1")
print(1 == int("1"))
# 特殊比较 数字和布尔表达式的比较
# 数字0代表False ,非0代表True
print(0 == False)
print(1 == True)
if 3-1 :
print("成立")
else :
print("不成立")
# 逻辑运算符 优先级 not > and > or
a = 3>1
b = 5<2
c = 8 == 8
d = 9 < 6
print(a and b)
print(a and c)
print(a or b)
print(not a )
print(not b)
# 优先级 not > and > or
r1= a and b or c and not b
print(r1)
r2=(a and (not b or c)) and d
print(r2)
# 多分支语句 elif
weight =input("输入体重:")
height = input("输入身高&#x
Python: 条件语句
最新推荐文章于 2024-01-30 10:28:09 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)