python学习11——if 语句。
2021-07-12 01:04
标签:round oom from and else too less foo 测试 输出结果: 注意: if 、elif、else 后需要加冒号。 数值型数据需要使用int()。 测试小游戏: python学习11——if 语句。 标签:round oom from and else too less foo 测试 原文地址:https://www.cnblogs.com/shannon-V/p/9550102.htmlpeople=int(input("How many people are there in this city?"))
cats = int(input("How many cats are there in this city?"))
dogs = int(input("How many dogs are there in this city?"))
if people cats:
print("Too many cats! The world is doomed!")
elif people > cats:
print("Not many cats! The world is saved!")
else:
print("We can‘t decide.")
dogs += 10
if people >= dogs:
print ("People are greater than or equal to dogs.")
else:
print("People are less than dogs")
print("Now you are lost in the forest, you can see a house in your left and a light comes from right, where do you want to go?")
print("1. To the house in the left.")
print("2. To the light in the right.")
choose_1=input("*")
if choose_1 == "1":
print("There are some food in the table, will you eat it?")
print("1. Yes, I\‘m so hungry.")
print("2. No, I will leave tomorrow.")
choose_2 =input("*")
if choose_2 =="1":
print("You ate poison and died, good job!")
else:
print("You wake up the other day, and find the way back home.")
elif choose_1=="2":
print("You find the thing that shines.\n1. You pick it up and hope it can help you find the way.\n2.You throw it away.")
choose_3=input("*")
if choose_3=="1":
print("It was a shining snake and you were biten then die. Good job!")
elif choose_3=="2":
print("You were lost in the forest forever.")
else:
print("You wake up and it was just a bad dream.")
else:
print("You stood here until the wolf came and ate you.")
上一篇:进程and线程and协程效率对比
文章标题:python学习11——if 语句。
文章链接:http://soscw.com/index.php/essay/103925.html