File tree 1 file changed +14
-6
lines changed
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 8
8
'/' : operator .truediv ,
9
9
}
10
10
11
- def operate ( operation ):
11
+ def chooseNum ( ):
12
12
num_1 = random .randint (1 , 10 )
13
13
num_2 = random .randint (1 , 10 )
14
- answer = operators .get (operation )(num_1 , num_2 )
14
+ return num_1 ,num_2
15
+
16
+ def operate (operation ):
17
+
18
+ pureInt = True
19
+ while pureInt :
20
+ num_1 ,num_2 = chooseNum ()
21
+ answer = operators .get (operation )(num_1 , num_2 )
22
+ if (operation == '/' and num_1 < num_2 ) or (operation == '/' and answer != num_1 // num_2 ):
23
+ pureInt = True
24
+ else :
25
+ pureInt = False
15
26
16
27
return answer ,num_1 ,num_2
17
28
@@ -20,10 +31,7 @@ def random_problem():
20
31
operation = random .choice (list (operators .keys ()))
21
32
answer ,num_1 ,num_2 = operate (operation )
22
33
23
- while (operation == '/' and num_1 < num_2 ) or (operation == '/' and answer != num_1 // num_2 ):
24
- print (str (answer ))
25
- answer ,num_1 ,num_2 = operate (operation )
26
-
34
+
27
35
print (f'What is { num_1 } { operation } { num_2 } ' )
28
36
return answer
29
37
You can’t perform that action at this time.
0 commit comments