Question: Write a program that asks the user to enter a series of single-digit numbers with nothing separating them. The program should display the sum of

Write a program that asks the user to enter a series of single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string. For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1, and 4.

Think about loops: how many times do we loop? Do we know how to find the length of a string? How do we access each member of a string??

This program should follow all of the criteria in the rubric and be in python. Please grade my program, give me feedback, and fix/add/change any parts if needed.

Write a program that asks the user to enter a series of

single-digit numbers with nothing separating them. The program should display the sum

def sum_of_digits(numbers): #calculate sum of digits sum = 0 #variable for sum of digits for digit_string in numbers: digit_int int(digit_string) sum = sum + digit_int #extracts digit and add to sum return sum def main(): numbers = input("Enter a series of single-digit numbers (without any spaces): ") sum=sum_of_digits (numbers) print('The sum of the digits in', numbers, 'is', sum) main() Criteria Ratings Pts 2 pts Total points You should make sure there are NO syntax errors.. O pts No Points Code has NO syntax errors If the code has syntax errors you need to fix them before you submit them 2 pts 4 pts Total Points If your code fails that is a bad thing... O pts No Points Code runs WITHOUT fatal errors Sometime the code will hit an error due to the input or improper programming logic. 4 pts 10 pts Total Points Make sure that your code produces the required output O pts No Points Code produces proper output. Logic errors allow the program to run- BUT - produces incorrect output. Make sure your code produces output that makes sense. 10 pts 3 pts 5 pts Medium Points Code meets requirements What does the assignment call for: 1)ask user for input; 2) using a loop add the values in the input; 3) output is correct and appropriate 10 pts Total points The program contains all the requirements: 1)ask user for input; 2) using a loop add the values in the input; 3) output is correct and appropriate The program missed one of the requirements: 11)ask user for input; 2) using a loop add the values in the input; 3) output is correct and appropriate Low points The program misses two of the requirements: 1)ask user for input; 2) using a loop add the values in the input; 3) output is correct and appropriate O pts No Points The program misses all three of the requirements: 1)ask user for input; 2) using a loop add the values in the input; 3) output is correct and appropriate 10 pts As always make sure your code contains: Your name, Class, Assignment is at the top of your code. Total Points: 26

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!