• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Dec 12th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from random import randint
2.
3. def display():
4.   print("Welcome to my awesome Math game")
5.   print("What is...")
6.
8.   x = randint(1,10)
9.   y = randint(1,10)
10.   op = ['+', '-', '*']
11.   op_int = randint(0,2)
12.
13.   print(x, op[op_int], y, '=')
14.
15.   ans = 0
16.   if op_int == 0:
17.     ans = x + y
18.   elif op_int == 1:
19.     ans = x - y
20.   else:
21.     ans = x * y
22.   return ans
23.
24. def getUserInput():
25.   user_ans = input("The answer is: ")
26.   user_ans = int(user_ans)
27.   return user_ans
28.
31.     print("You are correct!")
32.     return 1
33.   else:
35.     return 0
36.
37. score  = 0
38. repeat = True
39. display()
40. while repeat == True:
42.   #print(ca)
43.   ua = getUserInput()
44.   #print(ua)
45.   x = getResult(ca,ua)
46.   print()
47.   score = score + x
48.   print('Score:', score)
49.   print()
50.   r = input("Wanna go again?(y/n)")
51.   if r == 'n':
52.     repeat = False
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?