File tree Expand file tree Collapse file tree 6 files changed +53
-5
lines changed Expand file tree Collapse file tree 6 files changed +53
-5
lines changed Original file line number Diff line number Diff line change 1212[ ![ asciicast] ( https://asciinema.org/a/mkMowswaIrjQpgW8QyvtBGrHi.svg )] ( https://asciinema.org/a/mkMowswaIrjQpgW8QyvtBGrHi )
1313
1414### Brain-Gcd Test:
15- [ ![ asciicast] ( https://asciinema.org/a/Sx9fBpsgZRe3CRAhZfg5HmU8Y.svg )] ( https://asciinema.org/a/Sx9fBpsgZRe3CRAhZfg5HmU8Y )
15+ [ ![ asciicast] ( https://asciinema.org/a/Sx9fBpsgZRe3CRAhZfg5HmU8Y.svg )] ( https://asciinema.org/a/Sx9fBpsgZRe3CRAhZfg5HmU8Y )
16+
17+ ### Brain-Progression Test:
18+ [ ![ asciicast] ( https://asciinema.org/a/bas44UDYztpBdyHiJj0qDa0Xo.svg )] ( https://asciinema.org/a/bas44UDYztpBdyHiJj0qDa0Xo )
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ def main():
2626 if str (eval (question )) == str (user_answer ):
2727 print ('Correct!' )
2828 else :
29- print (f"'{ user_answer } ' is wrong answer ;(. Correct answer was '{ eval (question )} '" )
29+ print (f"'{ user_answer } ' is wrong answer "
30+ f";(. Correct answer was '{ eval (question )} '" )
3031 print (f"Let's try again, { name } !" )
3132 exit (0 )
3233 counter += 1
Original file line number Diff line number Diff line change @@ -23,14 +23,16 @@ def main():
2323 if user_answer == 'yes' :
2424 print ('Correct!' )
2525 else :
26- print (f"'{ user_answer } ' is wrong answer ;(. Correct answer was 'yes'." )
26+ print (f"'{ user_answer } ' is wrong answer "
27+ f";(. Correct answer was 'yes'." )
2728 print (f"Let's try again, { name } !" )
2829 exit (0 )
2930 else :
3031 if user_answer == 'no' :
3132 print ('Correct!' )
3233 else :
33- print (f"'{ user_answer } ' is wrong answer ;(. Correct answer was 'no'." )
34+ print (f"'{ user_answer } ' is wrong answer "
35+ f";(. Correct answer was 'no'." )
3436 print (f"Let's try again, { name } !" )
3537 exit (0 )
3638 counter += 1
Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ def main():
2424 if user_answer == str (gcd (num1 , num2 )):
2525 print ('Correct!' )
2626 else :
27- print (f"'{ user_answer } ' is wrong answer ;(. Correct answer was '{ gcd (num1 , num2 )} '." )
27+ print (f"'{ user_answer } ' is wrong answer "
28+ f";(. Correct answer was '{ gcd (num1 , num2 )} '." )
2829 print (f"Let's try again, { name } !" )
2930 exit (0 )
3031 counter += 1
Original file line number Diff line number Diff line change 1+ from random import randint
2+ from sys import exit
3+ from prompt import string
4+
5+ QUESTION = 'What number is missing in the progression?'
6+
7+
8+ def get_progression ():
9+ progression = []
10+ start = randint (1 , 20 )
11+ step = randint (1 , 5 )
12+ for i in range (10 ):
13+ progression .append (start )
14+ start += step
15+ prog_str = ' ' .join ([str (num ) for num in progression ])
16+ return prog_str , progression
17+
18+
19+ def main ():
20+ print ('Welcome to the Brain Games!' )
21+ name = string ('May I have your name? ' )
22+ print (f'Hello, { name } !' )
23+ print (QUESTION )
24+ counter = 0
25+ while counter < 3 :
26+ prog_str , progression = get_progression ()
27+ answer = progression [randint (0 , 9 )]
28+ changed_progression = prog_str .replace (str (answer ), '..' , 1 )
29+ print (f'Question: { changed_progression } ' )
30+ user_answer = string ('Your answer: ' )
31+ if user_answer == str (answer ):
32+ print ('Correct!' )
33+ else :
34+ print (f"'{ user_answer } ' is wrong answer "
35+ f";(. Correct answer was '{ answer } '." )
36+ print (f"Let's try again, { name } !" )
37+ exit (0 )
38+ counter += 1
39+ print (f'Congratulations, { name } !' )
40+ exit (0 )
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ brain-games = "brain_games.scripts.brain_games:main"
1717brain-even = " brain_games.scripts.brain_even:main"
1818brain-calc = " brain_games.scripts.brain_calc:main"
1919brain-gcd = " brain_games.scripts.brain_gcd:main"
20+ brain-progression = " brain_games.scripts.brain_progression:main"
2021
2122[tool .poetry .group .dev .dependencies ]
2223flake8 = " ^7.1.1"
You can’t perform that action at this time.
0 commit comments