天天看點

笨辦法學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