笨办法学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略
运行截图:
模块名称:测试.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加分习题28
- 笨办法学python加分习题29
- 笨办法学python加分习题16
- 笨办法学python加分习题21
- 笨办法学python加分习题39
- 笨办法学python加分习题24
- 笨办法学python加分习题38
- 笨办法学Python习题35-加分习题
- 笨办法学python加分习题31
- 笨办法学python加分习题36
- 笨办法学python加分习题20
- 笨办法学python加分习题34
- 笨办法学python加分习题32
- 笨办法学python加分习题15
- 笨办法学python加分习题17
- 笨办法学python加分习题26
- 笨办法学python加分习题35
- “笨办法”学Python习题41代码问题
- 笨办法学Python-习题7,8,9
- 《笨办法学python》加分习题30——我的答案