commit
60c2d18bfc
@ -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() |
Loading…
Reference in new issue