coin.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Taigabot 作者: FrozenPigs 项目源码 文件源码
def coin(inp, me=None):
    """coin [amount] -- Flips [amount] of coins."""

    if inp:
        try:
            amount = int(inp)
        except (ValueError, TypeError):
            return "Invalid input!"
    else:
        amount = 1

    if amount == 1:
        me("flips a coin and gets {}.".format(random.choice(["heads", "tails"])))
    elif amount == 0:
        me("makes a coin flipping motion with its hands.")
    else:
        heads = int(random.normalvariate(.5 * amount, (.75 * amount) ** .5))
        tails = amount - heads
        me("flips {} coins and gets {} heads and {} tails.".format(amount, heads, tails))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号