Skip to content

Commit dbe0a07

Browse files
committed
all changes 5-th step of project
1 parent 7b493f0 commit dbe0a07

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ package-install:
1414
python3 -m pip install --user dist/*.whl --break-system-packages
1515

1616
lint:
17-
poetry run flake8 brain_games
17+
poetry run flake8 brain_games/
1.49 KB
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+
import prompt
3+
4+
5+
NUMBERS_OF_ATTEMPTS = 3
6+
7+
8+
def game_parity_check():
9+
name = prompt.string('May I have your name? ')
10+
number_of_successful_attempts = 0
11+
print('Answer "yes" if the number is even, otherwise answer "no".')
12+
for _ in range(NUMBERS_OF_ATTEMPTS):
13+
random_nuber = random.randint(0, 100)
14+
parity = 'yes' if random_nuber % 2 == 0 else 'no'
15+
print(f'Question: {random_nuber}')
16+
answer = input('Your answer: ')
17+
if answer != parity:
18+
return f"'{answer}' is wrong answer ;(. Correct answer was '{parity}'\nLet's try again, Bill!"
19+
if answer == parity:
20+
number_of_successful_attempts += 1
21+
print('Correct!')
22+
if number_of_successful_attempts == NUMBERS_OF_ATTEMPTS:
23+
return f'Congratulations, {name}!'
24+
25+
26+
def main():
27+
print('Welcome to the Brain Games!')
28+
print(game_parity_check())
29+
30+
31+
if __name__ == '__main__':
32+
main()
736 Bytes
Binary file not shown.

dist/hexlet_code-0.1.0.tar.gz

1.27 KB
Binary file not shown.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ build-backend = "poetry.core.masonry.api"
2323

2424

2525
[tool.poetry.scripts]
26-
brain-games = "brain_games.scripts.brain_games:main"
26+
brain-games = "brain_games.scripts.brain_games:main"
27+
brain-even = "brain_games.scripts.brain_even:main"

0 commit comments

Comments
 (0)