Guest User

Untitled

a guest
Nov 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. Display the problem, stored in the parameter prob_spec in the IDLE shell
  2.  
  3. Grab the answer and strip the answer of whitespace to make processing easier
  4.  
  5. Compare the user’s solution to the correct one (stored in the parameter prob_sol)
  6.  
  7. If they got it right, tell them a happy message and return True
  8.  
  9. Otherwise tell them to try again and the number of tries they have left
  10.  
  11. If the number of tries exceeds the max_attempts then tell them they are out of tries AND what the actual answer was, and return False
  12.  
  13. from random import randint
  14.  
  15. def parse_line( prob_info ):
  16. list1 = []
  17. prob_info.find("<problem>")
  18. prob_info.find("<answer>")
  19. list1.append("<problem>")
  20. list1.append("<answer>")
  21. return list1
  22.  
  23. def read_file():
  24. index1 = input("What is the name of the file containing your practice problems: ")
  25. testfile = (index1, "r")
  26. for line in testfile:
  27. parse_line("probs.txt")
  28. list_of_probs = []
  29. list_of_probs.append(list1)
  30. return list_of_probs
  31.  
  32. def incorrect_feedback(list_of_msg):
  33. pos = randint(0, len(list_of_msg)- 1)
  34. return
  35.  
  36. def test_student(incorrect_msg, max_attempts, prob_spec, prob_sol):
  37. num_of_attempts = 0
  38. print(prob_spec)
  39. index2 = input("Your answer: ")
  40. sol.strip()
  41. if sol == prob_sol:
  42. print("Great job!")
  43. return True
  44. else:
  45. print(message, "You have", max_attempts - 1, "tries left.")
  46. if max_attempts == 0:
  47. print("Out of tries for this one - moving on. The answer was", prob_sol)
  48. return False
  49.  
  50. index = input("What is your name? ")
  51. print("Welcome", index, "to the math cognition tutor. You will practice some standard problems.")
  52. index3 = int(input("How many attempts do you want to give yourself per question? "))
  53. num_passed = 0
  54. read_file()
  55. for ele in list_of_probs:
  56. test_student(incorrect_msg, max_attempts, prob_spec, prob_sol)
  57. if test_student == True:
  58. num_passed = num_passed + 1
  59. print("Considering your final solutions, you got", num_passed, "problems correct out of 3")
Add Comment
Please, Sign In to add comment