同じ変数への代入等あり
テキストにあった内容を使って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) +"です")