پاسخ ها (1)
2
zero
ابتدا باید کتابخانه random رو نصب کنیم.
pip install random
سپس کد زیر را اجرا کنید
import random
_min=1
_max=99
number = random.randint(_min, _max)
player_name = input("hi, What's your name?")
number_of_guesses = 0
print('okay! \r\n'+ player_name+ ' please guess a number between ',_min, ' and ' ,_max ,':')
while number_of_guesses <= 20:
guess = int(input())
number_of_guesses += 1
if guess < number:
print('Your input number is ', guess,', guess is too low')
if guess > number:
print('Your input number is ', guess,', guess is too high')
if guess == number:
break
if guess == number:
print('You guessed the number ',number, ' in ' ,number_of_guesses, ' tries!')
else:
print('You did not guess the number, The number was ' ,number)
پاسخ به سوال