Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint, choice
- operators = "+-*/"
- def test():
- right = 0
- total = 0
- while True:
- op_choice = choice(operators)
- a = randint(-20, 20)
- b = randint(-20, 20)
- if op_choice == "/":
- if not b:
- continue
- if a % b:
- continue
- equation = f"{a} {op_choice} {b}"
- result = str(round(eval(equation)))
- u_inp = input(f"[{right}/{total}] What is {equation}? ")
- if result == u_inp:
- print("Correct!")
- right += 1
- else:
- print(f"Wrong, it was {result}")
- total += 1
- if __name__ == "__main__":
- test()
- # v0.0.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement