File tree Expand file tree Collapse file tree 11 files changed +45
-27
lines changed Expand file tree Collapse file tree 11 files changed +45
-27
lines changed Original file line number Diff line number Diff line change 1- from random import randint
2-
31import prompt
42
53counter = 0
4+
5+
66def greet_user ():
77 print ('Welcome to the Brain Games!' )
88 name = prompt .string ('May I have your name? ' )
99 print (f'Hello, { name } ' )
1010 return name
1111
12+
1213name = greet_user ()
1314
1415
Original file line number Diff line number Diff line change 1- from random import randint , choice
1+ from random import choice , randint
2+
3+ import prompt
24
35import brain_games .engine as engine
46
5- import prompt
67
78def b_calc ():
89 num1 = randint (0 , 30 )
@@ -18,10 +19,14 @@ def b_calc():
1819 if answer == str (exp ):
1920 engine .counter += 1
2021 print ('Correct!' )
21- num1 = randint (0 ,30 )
22- num2 = randint (0 ,30 )
22+ num1 = randint (0 , 30 )
23+ num2 = randint (0 , 30 )
2324 action = choice (operators )
2425 exp = eval (str (num1 ) + action + str (num2 ))
2526 else :
26- print (f"{ answer } is wrong answer ;(. Correct answer was { exp } . Let's try again, { engine .name } " )
27+ print (
28+ f"{ answer } is wrong answer ;(."
29+ f"Correct answer was { exp } .\n "
30+ f"Let's try again, { engine .name } "
31+ )
2732 quit ()
Original file line number Diff line number Diff line change 11from random import randint
22
3- import brain_games .engine as ngin
4-
53import prompt
64
5+ import brain_games .engine as ngin
6+
77
88def b_even ():
99 number = randint (1 , 100 )
@@ -19,7 +19,11 @@ def b_even():
1919 print ('Correct!' )
2020 ngin .counter += 1
2121 else :
22- print (f"{ answer } is wrong answer ;(. Correct answer was { real_answer } . Let's try again, { ngin .name } " )
22+ print (
23+ f"{ answer } is wrong answer ;(."
24+ f"Correct answer was { real_answer } .\n "
25+ f"Let's try again, { ngin .name } "
26+ )
2327 quit ()
2428
2529
Original file line number Diff line number Diff line change 11from random import randint
22
3- import brain_games .engine as ngin
4-
53import prompt
64
5+ import brain_games .engine as ngin
6+
77
88def b_gcd ():
99 a = randint (0 , 20 )
@@ -13,7 +13,7 @@ def b_gcd():
1313 print ('Find the greatest common divisor of given numbers.' )
1414 while ngin .counter < 3 :
1515 print (f'Question: { a } { b } ' )
16- answer = input ('Your answer: ' )
16+ answer = prompt . string ('Your answer: ' )
1717 while b != 0 :
1818 if max (numbers ) % min (numbers ) == 0 :
1919 gcd = min (numbers )
@@ -29,6 +29,10 @@ def b_gcd():
2929 b = randint (0 , 20 )
3030 ngin .counter += 1
3131 else :
32- print (f"{ answer } is wrong answer ;(. Correct answer was { gcd } . Let's try again, { ngin .name } " )
32+ print (
33+ f"{ answer } is wrong answer ;(."
34+ f"Correct answer was { gcd } \n ."
35+ f"Let's try again, { ngin .name } "
36+ )
3337 quit ()
3438
Original file line number Diff line number Diff line change 11from random import randint
22
3- import brain_games .engine as ngin
4-
53import prompt
64
5+ import brain_games .engine as ngin
6+
77
88def b_prime ():
99 print ('Answer "yes" if given number is prime. Otherwise answer "no".' )
@@ -25,5 +25,9 @@ def b_prime():
2525 num = randint (1 , 100 )
2626 div_counter = 0
2727 else :
28- print (f"{ answer } is wrong answer ;(. Correct answer was { real_answer } . Let's try again, { ngin .name } " )
28+ print (
29+ f"{ answer } is wrong answer ;(."
30+ f"Correct answer was { real_answer } .\n "
31+ f"Let's try again, { ngin .name } "
32+ )
2933 quit ()
Original file line number Diff line number Diff line change 1- from random import randint , choice
2-
3- import brain_games .engine as ngin
1+ from random import choice , randint
42
53import prompt
64
5+ import brain_games .engine as ngin
6+
77
88def make_progression ():
99 length = randint (5 , 12 )
@@ -13,6 +13,7 @@ def make_progression():
1313 a_progression .append (a_progression [- 1 ] + step )
1414 return a_progression
1515
16+
1617def b_progression ():
1718 print ('What number is missing in the progression?' )
1819 while ngin .counter < 3 :
@@ -31,5 +32,9 @@ def b_progression():
3132 q_seq .insert (i , '..' )
3233 ngin .counter += 1
3334 else :
34- print (f"{ answer } is wrong answer ;(. Correct answer was { missing_number } . Let's try again, { ngin .name } " )
35+ print (
36+ f"{ answer } is wrong answer ;(."
37+ f"Correct answer was { missing_number } .\n "
38+ f"Let's try again, { ngin .name } "
39+ )
3540 quit ()
Original file line number Diff line number Diff line change 11from brain_games .engine import run
2-
32from brain_games .games .b_calc_logic import b_calc
43
54
Original file line number Diff line number Diff line change 11from brain_games .engine import run
2-
32from brain_games .games .b_even_logic import b_even
43
54
Original file line number Diff line number Diff line change 11from brain_games .engine import run
2-
32from brain_games .games .b_gcd_logic import b_gcd
43
54
Original file line number Diff line number Diff line change 11from brain_games .engine import run
2-
32from brain_games .games .b_prime_logic import b_prime
43
54
You can’t perform that action at this time.
0 commit comments