笨办法学python 34

lesson 34
访问列表的元素

索引定义
关于序数(ordinal number)和基数(cardinal number)的知识
例如:
  基数:一、二、三、四、五、六、七、八、九、十。
  序数:第一、第二、第三、第四、第五、第六、第七、第八、第九、第十。
基数:
  在数学上,基数(cardinal number)是集合论中刻画任意集合大小的一个概念。两个能够建立元素间一一对应的集合称为互相对等集合。例如3个人的集合和3匹马的集合可以建立一一对应,是两个对等的集合。
序数:
  集合论基本概念之一,是日常使用的第一、第二等表示次序的数的推广。序数概念是建立在良序集概念之上的,而良序集又是偏序集、全序集的特殊情形。

lesson 35 分支和函数

from sys import exit
 
 
def goldRoom():
    # 房间内充满金子,你愿意出多少钱?
    print("This room is full of gold.How much do you take?")
    # 请输入金额
    next = input("please enter number> ")
    # 这里只是判断输入的数字中是否包含0和1
    if "0" in next or "1" in next:
        howMuch = int(next)
    else:
        # 同志,请输入数字
        dead("Man,learn to type a number.")
    if howMuch < 50:
        # 很好,你不是很贪婪,你赢了
        print("Nice,you're not greedy,you win!")
        exit(0)
    else:
        # 你太过贪婪了
        dead("You greedy bastard!")
 
 
def bearRoom():
    # 房间内有只熊
    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?")
    bearMoved = False
    while True:
        next = input("please enter take honey or taunt bear or taunt bear or open door> ")
        if next == "take honey":
            # 熊看着你,然后拍打你的脸
            dead("The bear looks at you then slaps your face off.")
        elif next == "taunt bear" and not bearMoved:
            # 熊已经从门口走了,你现在可以过去了。
            print("The bear has moved from the door.You can go through it now.")
            bearMoved = True
        elif next == "taunt bear" and bearMoved:
            # 熊会生气,咬你的木头
            dead("The bear gets pissed off and chews your log off.")
        elif next == "open door" and bearMoved:
            goldRoom()
        else:
            # 我不知道是什么意思。
            print("I got no idea what means.")
 
 
def cthulhuRoom():
    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("please enter flee or head> ")
    if "flee" in next:
        start()
    elif "head" in next:
        dead("Well that was tasty!")
    else:
        cthulhuRoom()
 
 
# 输出原因并中断运行
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("please enter left or right:> ")
    if next == "left":
        bearRoom()
    elif next == "right":
        cthulhuRoom()
    else:
        dead("You stumble around the room until you starve.")
 
 
start()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值