Skip to content

Commit 90b4e0f

Browse files
committed
Fix code by Ruff
1 parent 80ef62d commit 90b4e0f

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

brain_games/games/calc.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
import secrets
21
import operator
2+
import secrets
33

44

55
def calculate(num1: int, num2: int, operation: str) -> int:
66
"""Calculate the result of two numbers with given operation."""
7-
operations = {
8-
'+': operator.add,
9-
'-': operator.sub,
10-
'*': operator.mul
11-
}
7+
operations = {"+": operator.add, "-": operator.sub, "*": operator.mul}
128
return operations[operation](num1, num2)
139

1410

1511
def generate_round() -> tuple[str, str]:
1612
"""Generate a round for the calculator game."""
1713
num1 = secrets.randbelow(50) + 1 # 1-50
1814
num2 = secrets.randbelow(50) + 1 # 1-50
19-
operation = secrets.choice(['+', '-', '*'])
15+
operation = secrets.choice(["+", "-", "*"])
2016

2117
question = f"{num1} {operation} {num2}"
2218
correct_answer = str(calculate(num1, num2, operation))

brain_games/scripts/brain_calc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
from brain_games.engine import run_game
33
from brain_games.games.calc import generate_round
44

5-
DESCRIPTION = 'What is the result of the expression?'
5+
DESCRIPTION = "What is the result of the expression?"
66

77

88
def main():
99
run_game(DESCRIPTION, generate_round)
1010

1111

12-
if __name__ == '__main__':
12+
if __name__ == "__main__":
1313
main()

0 commit comments

Comments
 (0)