MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / random_problem

Function random_problem

Math_Game/math_game.py:17–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15 return validated_guess
16
17def random_problem():
18 operators = {
19 '+': operator.add,
20 '-': operator.sub,
21 '*': operator.mul,
22 '/': operator.truediv,
23 }
24
25 num_1 = random.randint(1, 10)
26 num_2 = random.randint(1, 10)
27 operation = random.choice(list(operators.keys()))
28 answer = float(round(operators.get(operation)(num_1, num_2),3))
29 print(f'What is {num_1} {operation} {num_2}')
30 return answer
31
32def ask_question():
33 answer = random_problem()

Callers 1

ask_questionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected