Skip to content

Commit

Permalink
update 'calc.py'
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVangeli committed Oct 3, 2024
1 parent e97383d commit 0c77909
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
Binary file modified brain_games/__pycache__/utils.cpython-310.pyc
Binary file not shown.
Binary file modified brain_games/games/__pycache__/calc.cpython-310.pyc
Binary file not shown.
Binary file modified brain_games/games/__pycache__/engine.cpython-310.pyc
Binary file not shown.
17 changes: 7 additions & 10 deletions brain_games/games/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@
from brain_games.utils import get_random_number


def get_calculation__result(number_one: int, number_two: int, operation: str) -> int:
def get_random_math_sign_and_result(number_one: int,
number_two: int,
operation: int) -> int:
"""
Вычисляет результат математической операции между двумя числами.
Args:
number_one (int): Первое число.
number_two (int): Второе число.
operation (str): Операция, которую нужно выполнить ('+', '-', '*').
operation (int): Операция, которую нужно выполнить ('+', '-', '*').
Returns:
int: Результат выполнения операции.
"""
match operation:
case "+":
return number_one + number_two
case "-":
return number_one - number_two
case "*":
return number_one * number_two
result = eval(f"{number_one} {operation} {number_two}")
return result


def get_numbers_and_calculation_result() -> tuple[str, str]:
Expand All @@ -41,7 +38,7 @@ def get_numbers_and_calculation_result() -> tuple[str, str]:
operation = random.choice(["+", "-", "*"])
question = f"{number_one} {operation} {number_two}"
correct_answer = str(
get_calculation__result(number_one, number_two, operation))
get_random_math_sign_and_result(number_one, number_two, operation))
return question, correct_answer


Expand Down
Binary file modified brain_games/scripts/__pycache__/brain_calc.cpython-310.pyc
Binary file not shown.

0 comments on commit 0c77909

Please sign in to comment.