Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Quizzma Latest Articles

5.2.8 Average Test Score CodeHS Answers

The most common answer for the 5.2.8 Average Test Score CodeHS is:

Score = 0
for For3Scores in range(1,4):
Average = int(input())
Score += Average

This code for calculating the average test score is almost correct, but there are a couple of improvements to be made for better clarity and accuracy:

  1. The print statement for the average should be placed outside the loop, so it only prints once after all scores are entered and summed.
  2. It’s good practice to use descriptive variable names. Instead of For3Scores and Average, names like score and total_score might be more appropriate.

Here’s the revised version of the code:

total_score = 0

for _ in range(3):  # Loop 3 times for 3 scores
    score = int(input("Enter score: "))  # Get the score from the user
    total_score += score  # Add the score to the total

average_score = total_score / 3  # Calculate the average
print("Average score:", average_score)  # Print the average

In this revised code:

  • The loop iterates three times, each time asking for a score and adding it to total_score.
  • The average is calculated as total_score / 3 and is printed after the loop completes. This ensures the average is only displayed once, after all the scores are entered.
  • Descriptive variable names are used for better readability.

Was this helpful?

Quizzma Team

Quizzma Team

The Quizzma Team is a collective of experienced educators, subject matter experts, and content developers dedicated to providing accurate and high-quality educational resources. With a diverse range of expertise across various subjects, the team collaboratively reviews, creates, and publishes content to aid in learning and self-assessment.
Each piece of content undergoes a rigorous review process to ensure accuracy, relevance, and clarity. The Quizzma Team is committed to fostering a conducive learning environment for individuals and continually strives to provide reliable and valuable educational resources on a wide array of topics. Through collaborative effort and a shared passion for education, the Quizzma Team aims to contribute positively to the broader learning community.

Related Posts

Leave a comment