-
Notifications
You must be signed in to change notification settings - Fork 0
/
ugadai_chislo.py
31 lines (29 loc) · 1012 Bytes
/
ugadai_chislo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import random
print('Угадай число от 1 до 100:')
count_try = 0
number_min, number_max = 1, 100
comp_number = random.randint(number_min, number_max)
print(f'Ваше число: {comp_number} ?')
while True:
user_answer = input()
count_try = count_try+1
if user_answer == '=':
print(f'ПОБЕДА!!! С {count_try} попытки' )
break
elif user_answer == '>':
try:
number_min = comp_number+1
comp_number = random.randint(number_min, number_max)
print(f'Ваше число: {comp_number} ?')
except ValueError:
print('Вы ошиблись')
break
elif user_answer == '<':
try:
number_max = comp_number-1
comp_number = random.randint(number_min, number_max)
print(f'Ваше число: {comp_number} ?')
except ValueError:
print('Вы ошиблись')
break
else: print('Вы ввели неверный знак,')