Pythonサイコロゲームの完全なコード

money = int(input( "初期金額を入力してください:"))

お金> 0:

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

guess = input(“ big or small:”)

guess!=“ big”およびguess!=“ small”の場合:

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

継続する

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

a == 1の場合:

Trueの間:

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

賭け>お金の場合:

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

そうしないと:

ランダムにインポート

num = random.randint(1,6)

印刷(かどうか)

0 <num <= 3 and guess ==“ small”または3 <num <= 6 and guess ==“ big”の場合:
print(“ you win!”)

money + =賭け

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

お金-=賭け

ブレーク

a == 2の場合:

ランダムにインポート

num = random.randint(1、6)

印刷(かどうか)

0 <num <= 3 and guess ==“ small”または3 <num <= 6 and guess ==“ big”の場合:
print(“ you win!”)

money + = 100

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

お金-= 100

プリント(「ゲームオーバー」)

おすすめ

転載: blog.csdn.net/li_little_flower/article/details/108712182