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.6 Running Total CodeHS Answers

We thoroughly check each answer to a question to provide you with the most correct answers. Found a mistake? Tell us about it through the REPORT button at the bottom of the page. Ctrl+F (Cmd+F) will help you a lot when searching through such a large set of questions.

The most common answer is:

Variable to keep track of the running total
total = 0
Ask the user fora value and add to total
for i in range(10):
next = int(input(“Enter a number: “))
total = total + next
Report the result
print “Sum: ” + str(total)

To ensure this program runs correctly and adheres to Python syntax, including using standard ASCII quotation marks and proper use of the print function in Python 3, here’s the revised version of your code:

"""
This program asks the user for ten numbers. It then reports the total of the
ten numbers.
"""

# Variable to keep track of the running total
total = 0

# Ask the user for a value and add to total
for i in range(10):
    next_number = int(input("Enter a number: "))  # 'next' is a built-in function, so it's better to use a different variable name like 'next_number'
    total = total + next_number

# Report the result
print("Sum: " + str(total))

This program will:

  • Initialize a total variable to keep track of the sum of the numbers entered by the user.
  • Use a for loop to prompt the user to enter ten numbers, adding each to the total.
  • Print the total sum after all ten numbers have been entered and summed.

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