ManningBri_M03ProgrammingAssignment1

py

School

Ivy Tech Community College, Columbus *

*We aren’t endorsed by this school

Course

140

Subject

Computer Science

Date

Feb 20, 2024

Type

py

Pages

1

Uploaded by KidAntelope7238

Report
''' The 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. Program: manningBri_M03ProgrammingAssignment1 Author: Bri Manning Date: 2/5/24 Version: 1.0 ''' def calculate_digit_sum(number_string): num_sum = 0 # for loop to conver all the character sin the input string into intergers for char in number_string: # turn each character into a interger num = int(char) # add the digit to the sum num_sum += num return num_sum # user inputs a series of single-digit numbers number_string = input("Enter a series of single-digit numbers: ") # calculate the sum of the single-digit numbers sum_of_nums = calculate_digit_sum(number_string) # output the result print("The sum of the single-digit numbers is:", sum_of_nums)
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help