File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import prompt
2+ import random
3+
4+ from brain_games .cli import welcome_user
5+
6+ DESCTRIPTION = 'Answer "yes" if the number is even, otherwise answer "no".'
7+
8+ def is_even (number ):
9+ return number % 2 == 0
10+
11+
12+ def brain_even ():
13+ name = welcome_user ()
14+ print (DESCTRIPTION )
15+
16+ correct_answers = 0
17+
18+ while correct_answers < 3 :
19+ question = random .randint (1 , 100 )
20+ print (f"Question: { question } " )
21+ answer = prompt .string ("You anwser: " ).lower ()
22+
23+ if answer == correct_answers :
24+ print ("Correct!" )
25+ correct_answers += 1
26+ else :
27+ print (f"'{ answer } ' is wrong answer ;(. Correct answer was '{ correct_answers } '." )
28+ print (f"Let's try again, { name } !" )
29+ return
30+
31+ print (f"Congratulations,{ name } !" )
32+
33+ if __name__ == '__main__' :
34+ brain_even ()
Original file line number Diff line number Diff line change 1- # ruff: noqa: F401
2- from brain_games .cli import welcome_user
3-
1+ #!/usr/bin/env python3
2+ import sys
3+ import os
4+ sys .path .insert (0 , os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
5+ from cli import welcome_user
46
57def main ():
68 welcome_user ()
79
8- if __name__ == '__main__' :
9- main ()
10-
10+ if __name__ == '__main__' :
11+ main ()
Original file line number Diff line number Diff line change @@ -22,3 +22,4 @@ dev = [
2222
2323[project .scripts ]
2424brain-games = " brain_games.scripts.brain_games:main"
25+ brain-even = " brain_games.scripts.brain_even:main"
Original file line number Diff line number Diff line change 77uv build
88
99package-install :
10- uv tool install dist/*.whl
10+ uv tool install dist/*.whl
11+
12+ lint :
13+ uv run ruff check brain_games
You can’t perform that action at this time.
0 commit comments