File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ import prompt
2+ import random
3+
4+
5+ def main ():
6+ print ('Welcome to the Brain Games!' )
7+ name = prompt .string ("May I have your name? " )
8+ print (f"Hello, { name } ! "
9+ f"Answer \' yes\' if the number is even, otherwise answer \' no\' ." )
10+ for i in range (3 ):
11+ number = random .randint (0 , 100 )
12+ print (f"Question: { number } " )
13+ answer = prompt .string ("Your answer: " )
14+ right_answer = 'yes' if is_even (number ) else 'no'
15+ if answer == right_answer :
16+ print ('Correct!' )
17+ else :
18+ print (f"'{ answer } ' is wrong answer ;(. Correct answer was '{ right_answer } '.\n "
19+ f"Let\' s try again, { name } !" )
20+ break
21+ else :
22+ print (f"Congratulations, { name } !" )
23+
24+
25+ def is_even (number : int ) -> bool :
26+ if number % 2 == 0 :
27+ return True
28+ else :
29+ return False
30+
31+
32+ if __name__ == '__main__' :
33+ main ()
You can’t perform that action at this time.
0 commit comments