您的位置:首页 > 编程语言 > Python开发

笨办法学python加分习题30

2018-02-07 15:42 393 查看
python版本:3      若有错误,敬请指出
模块名称:测试.py

#加分习题30
people = 30
cars = 40
buses = 15

if cars > people:
print("We should take the cars.")
elif cars < people:
print("We should not take the cars.")
else:
print("We can't decide.")

if buses > cars:
print("That's too many buses")
elif buses < cars:
print("Maybe we could take the buses.")
else:
print("We still can't decide.")

if people > buses:
print("Alright,let's just take the buses.")
else:
print("Fine,let's stay home then.")

#1
#如果if为False,则执行elif,若是elif为True,执行elif下面的代码块
#若是elif为False,则执行else下面的代码块
#2略
#3

if cars > people and buses < cars:
print("True")
if cars > people and buses <= cars:
print("True")
if cars > people and buses == cars:
print("True")
else:
print("False")
#4略


运行截图:

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python