_s8

Untitled

_s8
Nov 4th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. import random
  2.  
  3. # Please don't hate me for this
  4.  
  5. """
  6. 1 = Normal
  7.  
  8. """
  9. maxi = 5
  10. symbols = ['-', '+', '/', '*']
  11. prob = []
  12. for x in range(random.randint(2,5)):
  13.     created = ''
  14.     created += str(random.randint(1, maxi))+" "
  15.     created += str(random.choice(symbols))+" "
  16.     created += str(random.randint(1, maxi))+" "
  17.     prob.append(created)
  18.     prob.append(random.choice(symbols)+" ")
  19. del prob[len(prob)-1]
  20. problem = ''
  21. for t in prob:
  22.     problem += t
  23. exec('ans = round({}, 0)'.format(problem))
  24. print(ans)
  25. problem += "= "
  26. player_ans = input(problem)
  27. if int(player_ans) == ans:
  28.     print("Correct!")
  29. else:
  30.     print("Nope!!")
Advertisement
Add Comment
Please, Sign In to add comment