笨办法学python3 学习笔记 习题30 else和if
程序员文章站
2022-07-11 15:35:05
...
people = 40
cars =30
trucks = 15
if cars > people:
print("We should take the cars.")
print(">>>>>>>>>>after cars > people")
elif cars < people:
print("We should not take the cars.")
print(">>>>>>>>>>after cars < people")
else:
print("We can't decide.")
print(">>>>>>>>>>after cars people else")
if trucks > cars:
print("That's too many trucks.")
print(">>>>>>>>>>after trucks > cars")
elif trucks < cars:
print("Maybe we could take the trucks.")
print(">>>>>>>>>>after trucks < cars")
else:
print("We still can't decide.")
print(">>>>>>>>>>after trucks cars decide.")
if people > trucks:
print("Alright, let's just take the trucks.")
print(">>>>>>>>>>>after if")
else:
print("Fine, let's stay home then.")
print(">>>>>>>>>>>>>>>after else")
PS D:\pythonp> python ex30.py
We should take the cars.
Maybe we could take the trucks.
Alright, let's just take the trucks.
上一篇: 自定义函数
下一篇: 笨办法学Python3 习题39 字典