Skip to content

Commit b4d0295

Browse files
Initial project: brain_games
1 parent 8213d3c commit b4d0295

4 files changed

Lines changed: 46 additions & 7 deletions

File tree

brain_games/scripts/brain_even.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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()

brain_games/scripts/brain_games.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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

57
def main():
68
welcome_user()
79

8-
if __name__ == '__main__':
9-
main()
10-
10+
if __name__ == '__main__':
11+
main()

hexlet-code.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ dev = [
2222

2323
[project.scripts]
2424
brain-games = "brain_games.scripts.brain_games:main"
25+
brain-even = "brain_games.scripts.brain_even:main"

makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ build:
77
uv build
88

99
package-install:
10-
uv tool install dist/*.whl
10+
uv tool install dist/*.whl
11+
12+
lint:
13+
uv run ruff check brain_games

0 commit comments

Comments
 (0)