LoginSignup
0
0

More than 3 years have passed since last update.

九九のプログラム

Last updated at Posted at 2019-12-03

息子が九九の勉強をしていたので、高い商材を買わなくていいように、python3で九九のゲームを作成しました。

import random


point = 0

for i in range(10):
#    x = random.randint(1,9)
    x = 6
    y = random.randint(1,9)

    ans = 0

    try:
        print(str(i+1) + "問:" +str(x) + "×" + str(y) + "=")
        ans = int(input())

    except ValueError:
        print("数字が入力されていません")

    finally:
        if(ans == x*y):
            print("せいかいです")
            print("")
            point += 10
        else:
            print("まちがいです。せいかいは、"+str(x*y)+"です")
            print("")

print(str(point)  + "点ゲットしました")


while True:
    print("enterを入力してください")
    tmp = input()
    if tmp =="":
        break

0
0
2

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
0
0