Skip to content

Commit 2b37709

Browse files
committed
add brain_even and fix README.md
1 parent 4febd7d commit 2b37709

File tree

15 files changed

+199
-2
lines changed

15 files changed

+199
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.venv
2+
3+

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

@@ -13,6 +16,9 @@ publish:
1316
package-install:
1417
python3 -m pip install --user dist/*.whl
1518

19+
lint:
20+
poetry run ruff check brain_games
21+
1622

1723

1824

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
11
### Hexlet tests and linter status:
2-
[![Actions Status](https://github.com/NikLuki/python-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/NikLuki/python-project-49/actions)
2+
[![Actions Status](https://github.com/NikLuki/python-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/NikLuki/python-project-49/actions)
3+
4+
## Установка:
5+
Для установки используйте
6+
pip install brain_games
7+
8+
## Запуск игры:
9+
Для запуска ввести
10+
make brain-games
11+
Для игры brain-even:
12+
make brain-even
13+
14+
## Пример игры brain-even:
15+
https://asciinema.org/a/jC0AcWTwA02EvngLu5av4N3ry
16+
17+
## Победа или поражение:
18+
Ответьте верно (yes/no) на три вопроса подряд, чтобы выиграть
19+
При вводе неверного ответа, либо любых других символов - сообщение о проигрыше
20+
21+
22+

brain_games.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/usr/bin/env python3
449 Bytes
Binary file not shown.

brain_games/cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def welcome_user():
2+
print("Welcome to the Brain Games!")
3+
name = input("May I have your name? ")
4+
print(f"Hello, {name}!")
5+
1.11 KB
Binary file not shown.
19 Bytes
Binary file not shown.

brain_games/scripts/brain_even.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import random
2+
3+
def main():
4+
print('Welcome to the Brain Even Game!')
5+
name = input('May I have your name? ')
6+
print(f'Hello, {name}!')
7+
8+
rounds = 3
9+
for _ in range(rounds):
10+
number = random.randint(1, 100)
11+
correct_answer = 'yes' if number % 2 == 0 else 'no'
12+
print(f'Question: {number}')
13+
answer = input("Your answer (yes/no): ")
14+
15+
if answer == correct_answer:
16+
print('Correct!')
17+
else:
18+
print(f'Wrong! The correct answer was {correct_answer}.')
19+
break
20+
else:
21+
print('Congratulations, you won!')
22+
23+
if __name__ == '__main__':
24+
main()
25+

brain_games/scripts/brain_games.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
from brain_games.cli import welcome_user
2+
13
def main():
24

3-
print('Welcome to the Brain Games!')
5+
welcome_user()
46

57
if __name__ == '__main__':
68

79
main()
10+
11+

0 commit comments

Comments
 (0)