-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy2225_tabliczka_mnozenia.py
More file actions
52 lines (40 loc) · 963 Bytes
/
Copy pathpy2225_tabliczka_mnozenia.py
File metadata and controls
52 lines (40 loc) · 963 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# coded by h4sski
import random
min = 3
max = 10
def get_random():
return random.randrange(min, max)
def mnozenie(mistakes):
a = get_random()
b = get_random()
while True:
c = int(input(f'{a} * {b} = '))
c_correct = a * b
if c == c_correct:
break
else:
mistakes += 1
print('Zle, jeszcze raz:')
return mistakes
def dzielenie(mistakes):
a = get_random()
b = get_random()
while True:
c = int(input(f'{a*b} : {a} = '))
c_correct = b
if c == c_correct:
break
else:
mistakes += 1
print('Zle, jeszcze raz:')
return mistakes
def main():
mistakes = 0
for _ in range(20):
r = random.choice(['m', 'd'])
if r == 'm':
mistakes = mnozenie(mistakes)
else:
mistakes = dzielenie(mistakes)
print(f'Popoelniles {mistakes} bledow.')
main()