首页 > 代码库 > ex35.py
ex35.py
1 from sys import exit 2 3 def gold_room(): 4 print ("This room is full of gold. how much do you take?") 5 6 7 next = input(">") 8 if "0" in next or "1"in next: 9 how_much = int(next) 10 11 else: 12 dead("Man, learn to type a number.") 13 14 if how_much < 50: 15 print ("Nice. you‘re not greedy, you win!") 16 exit(0) 17 else: 18 dead("You greedy bastard!") 19 20 def bear_room(): 21 print ("This is a bear here.") 22 print ("the bear has a bunch of honey.") 23 print ("The fat bear is in front of another door") 24 print ("How are you going to move the bear?") 25 bear_moved = False 26 27 while True: 28 next = input(">") 29 30 if next == "take honey": 31 dead("The bear looks at you then slaps your face off.") 32 elif next == "Taunt bear" and not bear_moved: 33 print ("The bear has moved from the door. You can go through it now.") 34 bear_moved = True 35 elif next == "taunt bear" and bear_moved: 36 dead("The bear gets pissed off and chews your leg off.") 37 elif next == "open door" and bear_moved: 38 gold_room() 39 else: 40 print ("I got no idea what that means.") 41 42 def cthulhu_room(): 43 print ("Here you see the great evil cthulhu.") 44 print ("He, it, whatever stares at you and you go insane.") 45 print ("Do you flee for your life or eat your head?") 46 47 next = input (">") 48 49 if "flee" in next: 50 start() 51 elif "head" in next: 52 dead("Well that was tasty!") 53 else: 54 cthulhu_room() 55 56 def dead(why): 57 print (why, "Good job!") 58 exit(0) 59 60 def start(): 61 print ("You are in a dark room.") 62 print ("There is a door to your right and left.") 63 print("Which one do you take?") 64 65 next = input(">") 66 67 if next == "left": 68 bear_room() 69 elif next == "right": 70 cthulhu_room() 71 else: 72 dead("You stumble around the room until you starve.") 73 74 start() 75 76 77 78 79 80 81 82 83 84 85
ex35.py
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。