Review the following code and determine the error. def main(): test1 = int(raw_input("Enter score for first test: ")) test2 = int(raw_input("Enter score for first test: ")) test3 = int(raw_input("Enter score for first test: ")) avg_test_score = ( test1 + test2 + test2) / 3 print("Your average test score is: ", avg_test_score) main() The average test score should be multiplied by 0.7 after being divided by 3. The average test score should be multiplied by 0.7 before being divided by 3. The variable avg_test_score should print the statement average test score. The variable avg_test_score uses test2 twice, causing the calculation error.
The average test score should be calculated by adding the three test scores and then dividing by 3, right? But if you look closely at the line "avg_test_score = ( test1 + test2 + test2) / 3" you'll see that the code isn't actually adding the three test scores, is it? Instead of adding test1, test2, and test3, the code adds test1, test2, and test2 again.
Ohhh yes I see that
So the " The variable avg_test_score uses test2 twice, causing the calculation error."
Exactly. Nicely spotted :)
Thank you soo much!!!
Join our real-time social learning platform and learn together with your friends!