2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

数当てゲーム(Python3)改良版

Last updated at Posted at 2023-03-02

数当てゲーム

数当てゲームのプログラムを一部改良しました

# 数当てプログラム2
# 新規作成 2023/3/1
import random
# 名前を入力してもらい変数に代入する
name = input("Input your name ")
#正解の数値を乱数を使って作成
answer = random.randint(1,10)
#カウント回数
count = 0
while True:
  #数字を入力してもらい数値に変換して変数に代入する
  num = int(input("Input your number "))
  count += 1
  if answer == num:
    print(f"{name}さん、{count}回目で正解です")
    break
  elif answer > num:
    print(f"{name}さん、正解はもっと数字が大きいです")
  elif answer < num:
    print(f"{name}さん、正解はもっと数字が小さいです")
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?