美文网首页
笨方法学python 习题35

笨方法学python 习题35

作者: d1b0f55d8efb | 来源:发表于2017-07-24 17:30 被阅读0次
    from sys import exit
    
    def gold_room():
        print("This room is full of gold. How much do you take?")
    
        next = input("> ")
        if "0" in next or "1" in next:
            how_much = int(next)
        else:
            dead("Man, learn to type a number.")
    
        if how_much < 50:
            print ("Nice, you're not greedy, you win!")  #好,你不是贪婪,你就赢了
            exit(0)
        else:
            dead("You greedy bastard!")#你贪婪的混蛋
    
    def bear_room():
        print ("There is a bear here.")#这里有一只熊
        print ("The bear has a bunch of honey.")#这只熊有一堆的蜂蜜
        print("The fat bear is in front of another door.")#前面的肥熊是另一扇门
        print("How are you going to move the bear?")#你打算搬熊怎么样?
        bear_moved = False
    
        while True:
            next = input("> ")
    
            if next == "take honey":
                dead("The bear looks at you then slaps your face off.")#然后熊看着你打了你的脸
            elif next == "taunt bear" and not bear_moved: #嘲讽熊
                print ("The bear has moved from the door. You can go through it now.")#熊已经从门口。现在你可以浏览
                bear_moved = True
            elif next == "taunt bear" and bear_moved:
                dead("The bear gets pissed off and chews your leg off.")#熊变得生气,咬你的腿
            elif next == "open door" and bear_moved:
                gold_room()
            else:
                print ("I got no idea what that means.")#我不知道这意味着什么
    
    
    def cthulhu_room():
        print ("Here you see the great evil Cthulhu.")#这里你看到伟大的邪恶的恶魔。
        print ("He, it, whatever stares at you and you go insane.")#他,无论盯着你,你疯了
        print ("Do you flee for your life or eat your head?")#你对你的生活或逃离吃你的头吗?
        next = input("> ")
    
        if "flee" in next:
            start()
        elif "head" in next:
            dead("Well that was tasty!")#这是美味的
        else:
            cthulhu_room()
    
    
    def dead(why):
        print (why, "Good job!")
        exit(0)
    
    def start():
        print ("You are in a dark room.")#你是在一个黑暗的房间
        print ("There is a door to your right and left.")#有一个门左右
        print ("Which one do you take?")
    
        next = input("> ")
    
        if next == "left":
            bear_room()
        elif next == "right":
            cthulhu_room()
        else:
            dead("You stumble around the room until you starve.")
    
    
    start()
    
    You are in a dark room.
    There is a door to your right and left.
    Which one do you take?
    > left
    There is a bear here.
    The bear has a bunch of honey.
    The fat bear is in front of another door.
    How are you going to move the bear?
    > taunt bear
    The bear has moved from the door. You can go through it now.
    > open door
    This room is full of gold. How much do you take?
    > ds
    Man, learn to type a number. Good job!
    

    相关文章

      网友评论

          本文标题:笨方法学python 习题35

          本文链接:https://www.haomeiwen.com/subject/tvgdkxtx.html