Skip to content

Commit ea7ed39

Browse files
committed
Добавлена игра «Проверка на чётность» и добавлена аскинема в README.md
1 parent 1bcab4a commit ea7ed39

File tree

8 files changed

+45
-5
lines changed

8 files changed

+45
-5
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ install:
44
brain-games:
55
uv run brain-games
66

7-
build:
7+
clean-dist:
8+
rm -rf dist/
9+
10+
build: clean-dist
811
uv build
912

1013
package-install:
11-
uv tool install dist/*.whl
12-
14+
uv tool install --force dist/*.whl

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Demo: Brain Even Game
2+
3+
[![asciicast](https://asciinema.org/a/8DwwSSP9EF5y4tOtpDo6AnD9X.svg)](https://asciinema.org/a/8DwwSSP9EF5y4tOtpDo6AnD9X)
4+
15
### Hexlet tests and linter status:
26
[![Actions Status](https://github.com/dobro10k2/devops-engineer-from-scratch-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/dobro10k2/devops-engineer-from-scratch-project-49/actions)
37
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dobro10k2_devops-engineer-from-scratch-project-49&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=dobro10k2_devops-engineer-from-scratch-project-49)
472 Bytes
Binary file not shown.

brain_games/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
def welcome_user():
55
name = prompt.string('May I have your name? ')
66
print(f'Hello, {name}!')
7+
return name
88 Bytes
Binary file not shown.

brain_games/scripts/brain_even.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import random
2+
from brain_games.cli import welcome_user
3+
4+
5+
def is_even(number):
6+
"""Проверка, чётное ли число."""
7+
return number % 2 == 0
8+
9+
10+
def main():
11+
print('Answer "yes" if the number is even, otherwise answer "no".')
12+
name = welcome_user() # вернёт имя пользователя
13+
14+
rounds = 3
15+
for _ in range(rounds):
16+
number = random.randint(1, 100)
17+
print(f"Question: {number}")
18+
answer = input("Your answer: ").strip().lower()
19+
20+
correct_answer = "yes" if is_even(number) else "no"
21+
22+
if answer != correct_answer:
23+
print(
24+
f"'{answer}' is wrong answer ;(. Correct answer was '{correct_answer}'.\n"
25+
f"Let's try again, {name}!"
26+
)
27+
return
28+
29+
print("Correct!")
30+
31+
print(f"Congratulations, {name}!")
32+

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "hexlet-code"
3-
version = "0.3.0"
3+
version = "0.4.2"
44
description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.12"
@@ -22,6 +22,7 @@ dev = [
2222

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

2627
[tool.ruff]
2728
line-length = 80

uv.lock

Lines changed: 1 addition & 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)