Python掷色子游戏完整代码

money=int(input(“请输入初始金额:”))

while money>0:

print("你还有%s个金币"%money)

guess=input(“big or small:”)

if guess!=“big” and guess!=“small”:

    print("你输入有误,请重新输入!")

continue

# a为赌注    a=int(input("是否下赌注?1为下,2为不下:"))

if a==1:

while True:

        wager=int(input("赌注为:"))

if wager>money:

            print("你的金额不足,请重新下注!")

else:

import random

num=random.randint(1,6)

print(num)

if 0<num<=3 and guess==“small” or 3<num<=6 and guess==“big”:
print(“you win!”)

money+=wager

elif 0<num<=3 and guess==“big” or 3<num<=6 and guess==“small”:
print(“you lose!”)

money-=wager

break

if a==2:

import random

num=random.randint(1, 6)

print(num)

if 0<num<=3 and guess==“small” or 3<num<=6 and guess==“big”:
print(“you win!”)

money+=100

elif 0<num<=3 and guess==“big” or 3<num<=6 and guess==“small”:
print(“you lose!”)

money-=100

print(“game over”)

猜你喜欢

转载自blog.csdn.net/li_little_flower/article/details/108712182
今日推荐