Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import random
- total_time = 0
- score = 0
- operators = ["+", "-", "*"]
- for i in range(10):
- num1 = random.randint(10, 99)
- num2 = random.randint(10, 99)
- operator = random.choice(operators)
- if operator == "+":
- answer = num1 + num2
- elif operator == "-":
- answer = num1 - num2
- else:
- answer = num1 * num2
- start = time.time()
- print(f"What is {num1} {operator} {num2}?")
- guess = input("Please enter your answer here: ")
- end = time.time() - start
- guess = int(guess)
- total_time += end
- if guess == answer:
- score += 1
- total_time = round(total_time/60, 2)
- rank = round(score/total_time, 2)
- print(f"You got {score} out of 10 in {total_time} minutes. You got {rank} points per minute")
Advertisement
Add Comment
Please, Sign In to add comment