用python编一个扔骰子猜大小的游戏要求三局两胜制
用python编一个扔骰子猜大小的游戏,要求三局两胜制
◀◀◀点击图片进入游戏————◀◀◀◀———点击图片进入游戏———打麻将规则,打麻将必胜绝技,四川麻将游戏
搜集的资料:
import random
def game(w, l):
def winning():
print("You are right.")
again(w+1, l)
def losing():
print("You are wrong.")
again(w, l+1)
def again(w, l):
ans = input("Play again?(y/n)")
if ans == n:
print("You played %s rounds, and you won %s rounds" % (w+l, w))
elif ans == y:
game(w, l)
else:
again(w, l)
guess = input("Please input your guess(big/small): ")
dice = random.randrange(1, 7)
if guess == "small":
winning() if dice <= 3 else losing()
elif guess == "big":
winning() if dice >= 4 else losing()
else:
game(w, l)
if __name__ == __main__:
game(0, 0)
用python编一个扔骰子猜大小的游戏,要求三局两胜制
Comments
Post a Comment