欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

笨办法学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.
相关标签: 学习笔记 python