笨办法学python加分习题29
2018-02-07 14:22
429 查看
python版本:3 若有错误,敬请指出
模块名称:测试.py
#加分习题29
people = 20
cats = 30
dogs = 15
if people < cats:
print("Too many cats!The world is doomed!")
if people > cats:
print("Not many cats!The world is saved!")
if people < dogs:
print("The world is drooled on!")
if people > dogs:
print("The world is dry!")
dogs += 5
if people >= dogs:
print("People are greater than or equal to dogs.")
if people <= dogs:
print("People are less than or equal dogs.")
if people == dogs:
print("People are dogs.")
#http://blog.csdn.net/u011692485/article/details/76685431,参照了一下,谢谢
#1
#如果if语句判断为True,就会执行下面代码块
#2
#行尾的冒号的作用是告诉 Python 接下来你要创建一个新的代码区段
#3
#报错
#4
if True and False:
print("1")
else:
print("2")
if True or False:
print("1")
#5略
运行截图:
模块名称:测试.py
#加分习题29
people = 20
cats = 30
dogs = 15
if people < cats:
print("Too many cats!The world is doomed!")
if people > cats:
print("Not many cats!The world is saved!")
if people < dogs:
print("The world is drooled on!")
if people > dogs:
print("The world is dry!")
dogs += 5
if people >= dogs:
print("People are greater than or equal to dogs.")
if people <= dogs:
print("People are less than or equal dogs.")
if people == dogs:
print("People are dogs.")
#http://blog.csdn.net/u011692485/article/details/76685431,参照了一下,谢谢
#1
#如果if语句判断为True,就会执行下面代码块
#2
#行尾的冒号的作用是告诉 Python 接下来你要创建一个新的代码区段
#3
#报错
#4
if True and False:
print("1")
else:
print("2")
if True or False:
print("1")
#5略
运行截图:
相关文章推荐
- 笨办法学Python习题35-加分习题
- 笨办法学python加分习题38
- 笨办法学python加分习题24
- 笨办法学python加分习题30
- 笨办法学python加分习题21
- 笨办法学python加分习题15
- 笨办法学python加分习题17
- 笨办法学python加分习题34
- 笨办法学python加分习题31
- 笨办法学python加分习题36
- 笨办法学python加分习题35
- 笨办法学python加分习题16
- 笨办法学python加分习题32
- 笨办法学python加分习题28
- 笨办法学python加分习题39
- 笨办法学python加分习题20
- 笨办法学python加分习题26
- 笨办法学Python-习题45-End
- 笨办法学Python-习题13-17
- 笨办法学python习题18 命名、变量、代码和函数