You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
numerical_game/games.py

51 lines
966 B

import random
import time
ball = 0
work = True
def timer():
num_of_secs = 5
while num_of_secs:
m, s = divmod(num_of_secs, 60)
min_sec_format = '{:02d}:{:02d}'.format(m, s)
print(min_sec_format, end='\r')
time.sleep(1)
num_of_secs -= 1
def mat(a, b, m):
global ball
global work
match m:
case 1:
z = '+'
sum = a+b
case 2:
z = '-'
sum = a-b
case 3:
z = '*'
sum = a*b
case 4:
z = '/'
sum = a/b
print(a,z,b, '= ?')
if int(input('= ')) == sum:
ball = ball + 1
else:
work = False
print('Ошибка. Твои баллы: ', ball)
def score():
c1 = 1
c2 = 9
global ball
global work
while work:
a = random.randint(c1,c2)
b = random.randint(c1,c2)
m = random.randint(1,4)
mat(a, b, m)
score()