Skip to content

Commit c0fb26e

Browse files
committed
check 5
1 parent 1c7a403 commit c0fb26e

20 files changed

+62
-54
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.venv
22
.python-version
33
demo.cast
4-
__pycache__
4+
__pycache__/
55
.idea
66
.DS_Store
77
**/__pycache__/

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
[![Actions Status](https://github.com/s-gala/python-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/s-gala/python-project-49/actions)
33

44
### CodeClimate
5-
[![Maintainability](https://api.codeclimate.com/v1/badges/487e17fe16141caa4b2a/maintainability)](https://codeclimate.com/github/s-gala/python-project-49/maintainability)
5+
[![Maintainability](https://api.codeclimate.com/v1/badges/487e17fe16141caa4b2a/maintainability.svg)](https://codeclimate.com/github/s-gala/python-project-49/maintainability)
66

77
### Asciinema even
8-
[![asciicast]( https://asciinema.org/a/wRnu8Sf53kCCvUfgqQixs0EPh.svg )( https://asciinema.org/a/wRnu8Sf53kCCvUfgqQixs0EPh )
8+
[![asciicast]( https://asciinema.org/a/wRnu8Sf53kCCvUfgqQixs0EPh.svg )]( https://asciinema.org/a/wRnu8Sf53kCCvUfgqQixs0EPh )
99

1010
### Asciinema calc
11-
[![asciicast]( https://asciinema.org/a/S9Bly86EkmrpnTJhsAJU8pQDl.svg )( https://asciinema.org/a/S9Bly86EkmrpnTJhsAJU8pQDl )
11+
[![asciicast]( https://asciinema.org/a/S9Bly86EkmrpnTJhsAJU8pQDl.svg )]( https://asciinema.org/a/S9Bly86EkmrpnTJhsAJU8pQDl )
1212

1313
### Asciinema gcd
14-
[![asciicast]( https://asciinema.org/a/L5FDJeBgVySllsh5oELOwTtKa.svg )( https://asciinema.org/a/L5FDJeBgVySllsh5oELOwTtKa )
14+
[![asciicast]( https://asciinema.org/a/L5FDJeBgVySllsh5oELOwTtKa.svg )]( https://asciinema.org/a/L5FDJeBgVySllsh5oELOwTtKa )
1515

1616
### Asciinema progression
17-
[![asciicast]( https://asciinema.org/a/geOtpvl2IneSE65iIyp3BSoGY.svg )( https://asciinema.org/a/geOtpvl2IneSE65iIyp3BSoGY ))
17+
[![asciicast]( https://asciinema.org/a/geOtpvl2IneSE65iIyp3BSoGY.svg )]( https://asciinema.org/a/geOtpvl2IneSE65iIyp3BSoGY )
1818

1919
### Asciinema prime
20-
[![asciicast]( https://asciinema.org/a/j2PgQoMiKCmVM1duYVp8pnN3i.svg )( https://asciinema.org/a/j2PgQoMiKCmVM1duYVp8pnN3i )
20+
[![asciicast]( https://asciinema.org/a/j2PgQoMiKCmVM1duYVp8pnN3i.svg )]( https://asciinema.org/a/j2PgQoMiKCmVM1duYVp8pnN3i )
2121

2222
### Brain-games
2323
The game "Brain-games" includes 5 games.

brain_games/consts.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
INSTRUCTION_CALC = "What is the result of the expression?"
1+
CALC_INSTRUCTION = "What is the result of the expression?"
22

3-
INSTRUCTION_EVEN = 'Answer "yes" if the number is even, otherwise answer "no".'
3+
EVEN_INSTRUCTION = 'Answer "yes" if the number is even, otherwise answer "no".'
44

5-
INSTRUCTION_GCD = "Find the greatest common divisor of given numbers."
5+
GCD_INSTRUCTION = "Find the greatest common divisor of given numbers."
66

7-
INSTRUCTION_PRIME = \
7+
PRIME_INSTRUCTION = \
88
'Answer "yes" if given number is prime. Otherwise answer "no".'
99

10-
INSTRUCTION_PROGRESSION = "What number is missing in the progression?"
10+
PROGRESSION_INSTRUCTION = "What number is missing in the progression?"
11+
12+
COUNT_OF_ROUNDS = 3

brain_games/engine.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import prompt
22

3-
NUMBER_OF_ROUNDS = 3
3+
from brain_games.consts import COUNT_OF_ROUNDS
4+
5+
COUNT = COUNT_OF_ROUNDS
46

57

68
def game_engine(INSTRUCTION, game):
79

810
name = prompt.string('Welcome to the Brain Games!\nMay I have your name? ')
911
print(f'Hello, {name}!\n{INSTRUCTION}')
10-
for _ in range(NUMBER_OF_ROUNDS):
11-
random_question, right_answer = game()
12-
print(f"Question: {random_question}")
12+
for _ in range(COUNT):
13+
question, right_answer = game()
14+
print(f"Question: {question}")
1315
answer = prompt.string('Your answer: ')
1416
if right_answer == answer:
1517
print('Correct!')
1618
else:
17-
print(f"'{answer}' is wrong answer ;(. ", end='')
18-
print(f"Correct answer was '{right_answer}'.")
19-
print(f"Let's try again, {name}!")
19+
print(f"'{answer}' is wrong answer ;(. \
20+
Correct answer was '{right_answer}'.\nLet's try again, {name}!")
2021
return
2122
print(f"Congratulations, {name}!")
-1.07 KB
Binary file not shown.
-822 Bytes
Binary file not shown.
-723 Bytes
Binary file not shown.
-736 Bytes
Binary file not shown.
-1022 Bytes
Binary file not shown.

brain_games/games/calc.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import random
22

3-
from brain_games import consts
3+
from brain_games.consts import CALC_INSTRUCTION
44
from brain_games.engine import game_engine
55
from brain_games.utils import get_random_number
66

7-
INSTRUCTION = consts.INSTRUCTION_CALC
7+
INSTRUCTION = CALC_INSTRUCTION
88

99

1010
def get_question_answer():
1111
first_num, second_num = get_random_number(1, 100), get_random_number(1, 100)
12+
sign, right_answer = get_math_operation(first_num, second_num)
13+
question = f'{first_num} {sign} {second_num}'
14+
return question, right_answer
15+
16+
17+
def get_math_operation(first_num, second_num):
1218
math_operation = [('+', first_num + second_num),
13-
('-', first_num - second_num),
14-
('*', first_num * second_num),
19+
('-', first_num - second_num),
20+
('*', first_num * second_num),
1521
]
1622
random_math_operation = random.choice(math_operation)
17-
random_question = f'{first_num} {random_math_operation[0]} {second_num}'
18-
right_answer = str(random_math_operation[1])
19-
return random_question, right_answer
23+
return random_math_operation[0], str(random_math_operation[1])
2024

2125

2226
def start_calc():

0 commit comments

Comments
 (0)