Write a Python program that asks users to input an integer n

Write a Python program that asks users to input an integer number and print the summation of its digits and total number of its digits. (i.e., for n=35, sum is 3+5=8, and total number of digits is 2).

Solution

# Python Program to find number of digits,sum of Digits of a Number

N = int(input(\"Please Enter any integer Number: \"))
Sum = 0
count=0

while(N > 0):
Reminder = N % 10
Sum = Sum + Reminder
N = N //10
count=count+1

print(\"\ Sum of the digits integer Number = %d\" %Sum)
print(\"\ Total Number of digits = %d\" %count)

Output :

Please Enter any integer Number: 35

Sum of the digits integer Number = 8

Total Number of digits = 2

Write a Python program that asks users to input an integer number and print the summation of its digits and total number of its digits. (i.e., for n=35, sum is

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site