Ask your own question, for FREE!
Computer Science 9 Online
kekeman:

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.

SmokeyBrown:

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.

kekeman:

Ohhh yes I see that

kekeman:

So the " The variable avg_test_score uses test2 twice, causing the calculation error."

SmokeyBrown:

Exactly. Nicely spotted :)

kekeman:

Thank you soo much!!!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
2 days ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!