Skip to content

Commit 4dab504

Browse files
committed
lint: fix code style issues with Ruff
1 parent f08ae52 commit 4dab504

File tree

6 files changed

+24
-37
lines changed

6 files changed

+24
-37
lines changed

brain_games/cli.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
2-
31
import prompt
42

53

64
def welcome_user():
75
name = prompt.string("May I have your name? ")
8-
print(f"Hello, {name}!")
6+
print(f"Hello, {name}!")

brain_games/games/calculator.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
2-
from random import randint, choice
1+
from random import choice, randint
32

43

54
def calculator():
6-
75
x = randint(0, 100)
86
y = randint(0, 100)
9-
operator = choice(['+', '-', '*'])
7+
operator = choice(["+", "-", "*"])
108

119
match operator:
12-
case '+':
13-
random_expression = f'{x} + {y}'
10+
case "+":
11+
random_expression = f"{x} + {y}"
1412
correct_answer = str(x + y)
1513
return (random_expression, correct_answer)
16-
case '-':
17-
random_expression = f'{x} - {y}'
14+
case "-":
15+
random_expression = f"{x} - {y}"
1816
correct_answer = str(x - y)
1917
return (random_expression, correct_answer)
20-
case '*':
21-
random_expression = f'{x} * {y}'
18+
case "*":
19+
random_expression = f"{x} * {y}"
2220
correct_answer = str(x * y)
2321
return (random_expression, correct_answer)
24-
25-
26-

brain_games/games/check_even.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
2-
31
from random import randint
42

53

64
def check_even():
7-
85
random_number = randint(0, 100)
9-
correct_answer = 'yes' if random_number % 2 == 0 else 'no'
6+
correct_answer = "yes" if random_number % 2 == 0 else "no"
107

118
return (random_number, correct_answer)
12-

brain_games/games/start_game.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
2-
31
import prompt
4-
from brain_games.games.check_even import check_even
2+
53
from brain_games.games.calculator import calculator
4+
from brain_games.games.check_even import check_even
65

76

87
def start_game():
9-
print('Welcome to the Brain Games!')
8+
print("Welcome to the Brain Games!")
109
user_name = prompt.string("May I have your name? ")
1110
print(f"Hello, {user_name}!")
12-
number_game = prompt.integer('Choose a game: 1 - "checking for parity", 2 - "calculator" ')
11+
number_game = prompt.integer(
12+
'Choose a game: 1 - "checking for parity", 2 - "calculator" '
13+
)
1314

14-
1515
games = {1: check_even, 2: calculator}
1616
game_func = games.get(number_game)
1717

1818
if number_game == 1:
1919
print('Answer "yes" if the number is even, otherwise answer "no".')
2020
elif number_game == 2:
21-
print('What is the result of the expression?')
21+
print("What is the result of the expression?")
2222
elif number_game not in games:
2323
print("There is no such number\nLet's try again, {user_name}!")
2424

25-
2625
correct_answers_count = 0
2726

2827
while correct_answers_count < 3:
2928
random_number, correct_answer = game_func()
30-
print(f'Question: {random_number}')
29+
print(f"Question: {random_number}")
3130
user_answer = input("Your answer: ")
3231

3332
if user_answer == correct_answer:
34-
print('Correct!')
33+
print("Correct!")
3534
correct_answers_count += 1
3635
else:
37-
print(f"'{user_answer}' is wrong answer ;(. Correct answer was '{correct_answer}'.\nLet's try again, {user_name}!")
36+
print(f"'{user_answer}' is wrong answer ;(. Correct answer was '{correct_answer}'.")
37+
print("Let's try again, {user_name}!")
3838
break
3939

4040
if correct_answers_count == 3:
41-
print(f'Congratulations, {user_name}!')
41+
print(f"Congratulations, {user_name}!")

brain_games/scripts/brain_even.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
2-
31
from brain_games.games.start_game import start_game
42

53

64
def main():
75
start_game()
86

7+
98
if __name__ == "__main__":
10-
main()
9+
main()

brain_games/scripts/brain_games.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from brain_games.games.start_game import start_game
32

43

0 commit comments

Comments
 (0)