LoginSignup
1
1

More than 1 year has passed since last update.

[Guess the Number] 数字を当てるゲームの実装(Python)

Posted at

## 目的
Guess the Numberプログラムが実装できる

Guess the Numberとは

プログラムがランダムに数字を選び、プレイヤーがその数字を当てるゲームですね!

実装例

guess_the_number.py
import random

number = random.randint(1, 100)
guess = None

while guess != number:
    guess = int(input("Guess the number (1-100): "))
    if guess < number:
        print("Too low.")
    elif guess > number:
        print("Too high.")

print("You win! The number was", number)

一人寂しくなった時はこのゲームで遊んでみてください🐰

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