Question: Write a Python program that gets an integer input from the user and calculates the sum of the digits in it . Steps: - Create

Write a Python program that gets an integer input from the user and calculates the sum of the digits in
it.
Steps:
- Create a file with the name findSum.py
- Get the number from the user using the input function.
- Initialize a variable sum to 0
- Write the logic to find the sum of the digits of the number (Use while loop).(Hint: Extract last digit
of the number, add it to the sum and remove that digit from the number)
- Print the sum.
Sample Input:
Enter a number: 1236
Output:
Sum of the digits: 12

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 Programming Questions!