1. 程式人生 > >《笨方法學Python 3》31. 作出決定

《笨方法學Python 3》31. 作出決定

知識點:

本節課重點是講你可以在 if 語句內部再放一個 if 語句。還有Zed的垃圾小遊戲,機翻,不明所以,完全get不到他的點。

基礎練習:

print("""You enter a dark room with two doors.
Do you go throgh door #1 or door #2?
///你走進一間有兩扇門的黑暗房間。
你是去1號門還是2號門?""")

door = input("> ")
if door == "1":
	print("There's a giant bear here eating a cheese cake.///這裡有一隻大熊正在吃乳酪蛋糕。")
	print("What do you want to do?///你想做什麼?")
	print("1. Take the cake>///拿蛋糕")
	print("2. Scream at the bear.///對著熊尖叫。")
	
	bear = input("> ")
	
	if bear == "1":
		print("The bear eats your face off.  Good job!///熊吃掉你的臉。幹得好!")
	elif bear == "2":
		print("The bear eats your legs off.  Good job!///熊把你的腿吃了。幹得好!")
	else:
		print(f"Well, doing {bear} is probably better.///好吧,選{bear}可能更好。")
		print("Bear runs away.///熊跑開了。")

elif door == "2":
	print("You stare into the endless abyss at Cthulhu's retina.///你凝視著Cthulhud的視網膜上無盡的深淵。")
	print("1. Blueberries.///藍莓")
	print("2. Yellow jacket clothespins.///黃色夾克的衣夾。")
	print("3. Understanding revolvers yelling melodies.///理解旋轉的旋律。")
	
	insanity = input("> ")
	
	if insanity == "1" or insanity == "2":
		print("Your body survives powered by a mind of jello.///你的身體靠果凍來維持生存。")
		print("Good job!///幹得好!")
	else:
		print("The insanity rots your eyes into a pool of muck.///精神錯亂把你的眼睛腐蝕成一堆糞。")
		print("Good job!///幹得好!")

else:
	print("You stumble around and fall on a knife and die,  Good job!///你跌跌撞撞地跌倒在刀下死去,幹得好!")	

結果:

反正就是讓你不得好死!!! 

END!!!