Question: Complete the check_solution() function that takes the following 3 integer parameters: The parameter user_solution that is assigned the user's answer to the mathematical expression generated
Complete the check_solution() function that takes the following 3 integer parameters:
- The parameter user_solution that is assigned the user's answer to the mathematical expression generated by the quiz.
- The parameter solution that is assigned the actual solution to the mathematical expression generated by the quiz.
- The parameter correct_answer_count that is assigned the number of questions the user has currently answered correctly.
The check_solution() function needs to check whether the user_solution and the solution are the same. If they are, the function should print "Correct" and then increment correct_answer_count by 1. Otherwise, the function should print "Incorrect". Finally, the function should return the correct_answer_count. Some examples of the function being used are shown below.
For example:
| Test | Result |
|---|---|
count = 5 user_solution = 10 solution = 10 count = check_solution(user_solution, solution, count) print("The correct count is now", count) | Correct The correct count is now 6 |
count = 5 user_solution = 10 solution = 7 count = check_solution(user_solution, solution, count) print("The correct count is now", count) | Incorrect The correct count is now 5 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
