天天看点

笨办法学python加分习题29

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略
           

运行截图:

笨办法学python加分习题29