Skip to content

Commit

Permalink
refactor: in calc.py limited the range of number selection and remove…
Browse files Browse the repository at this point in the history
…d the possibility of getting a negative answer
  • Loading branch information
Vitaly Chasovskikh committed Apr 14, 2024
1 parent f569423 commit 9d0c4d2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions brain_games/games/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ def logic():
Create two random numbers, chose a random operator,
create and return a question and the expected answer.
"""
number_1 = randrange(100)
number_2 = randrange(100)
number_1 = randrange(50)
number_2 = randrange(10)
if number_1 < number_2:
number_1, number_2 = number_2, number_1
operator = choice(['+', '-', '*'])
question = f'{number_1} {operator} {number_2}'
calc_perfect_answer = eval(question)
Expand Down

0 comments on commit 9d0c4d2

Please sign in to comment.