JumpYScriptsz

Maths game V2

Jun 29th, 2021 (edited)
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.88 KB | None | 0 0
  1. # ==== Credit and information ==== #
  2.  
  3. import random
  4.  
  5. # CREATOR: https://pastebin.com/u/JumpYScriptsz
  6. # STATUS: working!
  7. # check here for updates: https://pastebin.com/sRKki8t9
  8.  
  9. # welcome to Maths game v2!
  10.  
  11. # ====== ERRORS ====== #
  12.  
  13. # -number of goes have to be above 0
  14. # -custom questions (range) can be broken sometimes with ranging between 2 numbers
  15. # -the "MODES" have to be typed exactly as they are written
  16.  
  17. # variables #
  18.  
  19. correct = 0
  20. incorrect = 0
  21. points = 0
  22.  
  23. # main settings / modification #
  24. print("what would you like to practice?")
  25. print()
  26. print("addition, +")
  27. print("subtraction, -")
  28. print("multiplication, *")
  29. print("powers, **")
  30. print()
  31. rr = input(": ")
  32.  
  33. v = int(input("how many goes do you want: "))
  34. print("what mode do you want: ")
  35. print()
  36. print("======= MODES =======")
  37. print("easy")
  38. print("normal")
  39. print("hard")
  40. print("EXTREME")
  41. print("INSANE")
  42. print("custom")
  43. print()
  44.  
  45. r = input(": ")
  46.  
  47. if rr == "*":
  48.    
  49.     # change the v numbers to what fits you or leave them
  50.  
  51.     if r == "easy": # e.g. 2 * 5
  52.         v1 = 1 # from range 1
  53.         v2 = 5 # to 5
  54.         v3 = 1 # second range
  55.         v4 = 5 # to 5
  56.     elif r == "normal":
  57.         v1 = 2
  58.         v2 = 9
  59.         v3 = 2
  60.         v4 = 12
  61.     elif r == "hard":
  62.         v1 = -8
  63.         v2 = 13
  64.         v3 = -8
  65.         v4 = 12
  66.     elif r == "EXTREME":
  67.         v1 = -14
  68.         v2 = 13
  69.         v3 = -6
  70.         v4 = 13
  71.     elif r == "INSANE":
  72.         v1 = -20
  73.         v2 = 15
  74.         v3 = -30
  75.         v4 = 30
  76.     elif r == "custom":
  77.         v1 = int(input("enter the first number range: "))
  78.         v2 = int(input("enter the second number range: "))
  79.         v3 = int(input("enter a lower number than your first number: "))
  80.         v4 = int(input("enter the second number range: "))
  81.     else:
  82.         print("not valid mode - restart the program")
  83. elif rr == "+":
  84.     if r == "easy": # e.g. 2 + 5
  85.         v1 = 1 # from range 1
  86.         v2 = 10 # to 5
  87.         v3 = 1 # second range
  88.         v4 = 10 # to 5
  89.     elif r == "normal":
  90.         v1 = 5
  91.         v2 = 50
  92.         v3 = 5
  93.         v4 = 50
  94.     elif r == "hard":
  95.         v1 = -20
  96.         v2 = 20
  97.         v3 = -20
  98.         v4 = 20
  99.     elif r == "EXTREME":
  100.         v1 = -50
  101.         v2 = 70
  102.         v3 = -60
  103.         v4 = 70
  104.     elif r == "INSANE":
  105.         v1 = -100
  106.         v2 = 15
  107.         v3 = -100
  108.         v4 = 30
  109.     elif r == "custom":
  110.         v1 = int(input("enter the first number range: "))
  111.         v2 = int(input("enter the second number range: "))
  112.         v3 = int(input("enter a lower number than your first number: "))
  113.         v4 = int(input("enter the second number range: "))
  114.     else:
  115.         print("not valid mode - restart the program")
  116. elif rr == "-":
  117.     if r == "easy": # e.g. 2 - 5
  118.         v1 = 1 # from range 1
  119.         v2 = 5 # to 5
  120.         v3 = 1 # second range
  121.         v4 = 5 # to 5
  122.     elif r == "normal":
  123.         v1 = 2
  124.         v2 = 30
  125.         v3 = 2
  126.         v4 = 30
  127.     elif r == "hard":
  128.         v1 = -10
  129.         v2 = 50
  130.         v3 = -10
  131.         v4 = 50
  132.     elif r == "EXTREME":
  133.         v1 = -50
  134.         v2 = 50
  135.         v3 = -50
  136.         v4 = 50
  137.     elif r == "INSANE":
  138.         v1 = -200
  139.         v2 = 200
  140.         v3 = -200
  141.         v4 = 200
  142.     elif r == "custom":
  143.         v1 = int(input("enter the first number range: "))
  144.         v2 = int(input("enter the second number range: "))
  145.         v3 = int(input("enter a lower number than your first number: "))
  146.         v4 = int(input("enter the second number range: "))
  147.     else:
  148.         print("not valid mode - restart the program")
  149. elif rr == "**":
  150.     if r == "easy":
  151.         v1 = 1
  152.         v2 = 4
  153.         v3 = 1
  154.         v4 = 3
  155.     elif r == "normal":
  156.         v1 = 2
  157.         v2 = 4
  158.         v3 = 2
  159.         v4 = 6
  160.     elif r == "hard":
  161.         v1 = -3
  162.         v2 = 10
  163.         v3 = -4
  164.         v4 = 10
  165.     elif r == "EXTREME":
  166.         v1 = -12
  167.         v2 = 6
  168.         v3 = -12
  169.         v4 = 8
  170.     elif r == "INSANE":
  171.         v1 = -20
  172.         v2 = 25
  173.         v3 = -20
  174.         v4 = 25
  175.     elif r == "custom":
  176.         v1 = int(input("enter the first number range: "))
  177.         v2 = int(input("enter the second number range: "))
  178.         v3 = int(input("enter a lower number than your first number: "))
  179.         v4 = int(input("enter the second number range: "))
  180.     else:
  181.         print("not valid mode - restart the program")
  182.  
  183. y = input("show answer? DISABLED D / ENABLED E: ") # type D or E to disable / enable this
  184.  
  185. # random multiplication questions
  186.  
  187. for t in range(1, 1+v):
  188.     number = random.randint(v1, v2)
  189.     number2 = random.randint(v3, v4)
  190.     if rr == "*":
  191.         correctAnswer = number*number2
  192.         print(number, "x", number2)
  193.     elif rr == "+":
  194.         correctAnswer = number+number2
  195.         print(number, "+", number2)
  196.     elif rr == "-":
  197.         correctAnswer = number-number2
  198.         print(number, "-", number2)
  199.     elif rr == "**":
  200.         correctAnswer = number**number2
  201.         print(number, "by the power of", number2)
  202.     i = int(input(""))
  203.     if i == correctAnswer:
  204.         if y == "E":
  205.             print("")
  206.             correct = correct + 1
  207.             points = points + 225
  208.         else:
  209.             print("correct!")
  210.             correct = correct + 1
  211.             points = points + 115
  212.     elif i != correctAnswer:
  213.         if y == "E":
  214.             print("")
  215.             incorrect = incorrect + 1
  216.         else:
  217.             print("incorrect answer! answer is", correctAnswer)
  218.             incorrect = incorrect + 1
  219.     else:
  220.         print("error occured")
  221.  
  222. # statistics #
  223.        
  224. questions = correct + incorrect
  225. total = correct / questions * 100
  226.  
  227. print()
  228. print("======= STATISTICS =======")
  229. print()
  230. print("correct answers:", correct)
  231. print("incorrect answers:", incorrect)
  232. print("Total points gained:", points)
  233. print()
  234. print("number of goes input: ", v)
  235. print()
  236. print("ACCURACY:", total, "%")
  237.  
Add Comment
Please, Sign In to add comment