File tree Expand file tree Collapse file tree 3 files changed +1
-38
lines changed Expand file tree Collapse file tree 3 files changed +1
-38
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import prompt
2- import random
3-
4-
5- MIN_NUM , MAX_NUM = 1 , 150
6-
7-
8- def is_even (num ):
9- return num % 2 == 0
10-
11-
12- def run_even_game ():
13- print ('Welcome to the Brain Games!' )
14- name = prompt .string ('May I have your name? ' )
15- print (f'Hello, { name } ' )
16- print ('Answer "yes" if the number is even, otherwise answer "no".' )
17-
18- count_tries = 0
19-
20- while count_tries < 3 :
21- num = random .randint (MIN_NUM , MAX_NUM )
22- correct_answer = 'yes' if is_even (num ) else 'no'
23- print (f'Question: { num } ' )
24- answer = prompt .string ('Your answer: ' )
25-
26- if answer == correct_answer :
27- print ('Correct!' )
28- count_tries += 1
29- else :
30- print (f"'{ answer } ' is wrong answer ;(. Correct answer was '{ correct_answer } '."
31- f"Let's try again, { name } !" )
32- count_tries = 0
33-
34- print (f'Congratulations, { name } !' )
1+ from brain_games .games .even import run_even_game
352
363
374def main ():
Original file line number Diff line number Diff line change 1- # from brain_games.module import greet
21from brain_games .cli import welcome_user
32
43
54def main ():
6- # greet()
75 welcome_user ()
86
97
You can’t perform that action at this time.
0 commit comments