3
2

More than 3 years have passed since last update.

pythonでスゴロクゲームと足し算ゲーム

Posted at

同じ変数への代入等あり

テキストにあった内容を使ってpythonの挙動確認と備忘録

30までの交互スゴロクゲーム

pl_pos = 1
com_pos = 1

while True:

    input("enter-playerが動く")
    pl_pos = pl_pos + random.randint(1,6)

    if pl_pos>30:
        pl_pos = 30

    banmen()

    if pl_pos ==30:
        print("plのかち")
        break

    input("enter-comが動く")
    com_pos = com_pos + random.randint(1,6)

    if com_pos>30:
        com_pos = 30

    banmen()

    if com_pos ==30:
        print("comのかち")
        break

足し算ゲーム

A = random.randint(1,100)
B = random.randint(1,100)

correct = A + B

ans = input("A = "+ str(A) + " B = "+str(B) +" A+Bの合計は?")
if ans == str(correct):
    print("正解")
else:
    print("違います" + str(correct) +"です")

以上

Pythonでつくる ゲーム開発 入門講座より

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2