commit 60c2d18bfc1d44cf6d664c98a9a4ada6b21ef273 Author: joker Date: Fri Dec 16 09:19:39 2022 +0300 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/games.py b/games.py new file mode 100644 index 0000000..2d95ed4 --- /dev/null +++ b/games.py @@ -0,0 +1,51 @@ +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() \ No newline at end of file