Skip to content

Commit 5760e48

Browse files
committed
brain-even project
1 parent 78a62ca commit 5760e48

File tree

12 files changed

+136
-6
lines changed

12 files changed

+136
-6
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ install:
44
brain-games:
55
poetry run brain-games
66

7+
brain-even:
8+
poetry run brain-even
9+
710
build:
811
poetry build
912

@@ -12,3 +15,6 @@ publish:
1215

1316
package-install:
1417
python3 -m pip install --user dist/*.whl
18+
19+
lint:
20+
poetry run flake8 brain_games

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
### Hexlet tests and linter status:
2-
[![Actions Status](https://github.com/Nurzhan2023/python-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/Nurzhan2023/python-project-49/actions)
2+
[![Actions Status](https://github.com/Nurzhan2023/python-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/Nurzhan2023/python-project-49/actions)
3+
4+
5+
https://asciinema.org/connect/9023391f-0a2a-4d77-92f4-c89667a988b0

brain_games/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
0 Bytes
Binary file not shown.

brain_games/scripts/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
0 Bytes
Binary file not shown.
1.11 KB
Binary file not shown.

brain_games/scripts/brain_even.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# brain_games/scripts/brain_even.py
2+
import prompt
3+
import random
4+
5+
6+
def main():
7+
ROUNDS_COUNT = 3
8+
9+
10+
def generate_round():
11+
number = random.randint(1, 100)
12+
question = str(number)
13+
correct_answer = "yes" if number %2 == 0 else "no"
14+
return question, correct_answer
15+
16+
print("Welcome to the Brain Games!")
17+
name = prompt.string("May I have your name?")
18+
print(f"Hello, {name}!")
19+
print('Answer "Yes" if the number is even, otherwise answer "no".')
20+
21+
22+
for i in range(ROUNDS_COUNT):
23+
question, correct_answer = generate_round()
24+
print(f"Question: {question}")
25+
answer = prompt.string("Your answer: ").strip().lower()
26+
27+
if answer != correct_answer:
28+
print(f"'{answer}' is wrong answer ;(. Correct answer was '{correct_answer}'.)")
29+
print(f"Let's try again, {name}!")
30+
return
31+
32+
else:
33+
print("Correct!")
34+
35+
36+
print(f"Congratulations, {name}!")
37+
38+
39+
if __name__ == "__main__":
40+
main()
41+
42+
43+
44+
45+
46+

brain_games/scripts/brain_games.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#! /usr/bin/env python3
1+
#! /usr/bin/env python3
22
# brain_games/scripts/brain_games.py
3-
43
from brain_games.cli import welcome_user
54

5+
66
def main():
77
welcome_user()
88

9+
910
if __name__ == "__main__":
1011
main()

poetry.lock

Lines changed: 50 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)