Programming Example

Write a Python program to input any number from user and find its sum of digit

Solution

def sumOfDigit(num):
    sum=0
    while num>0:
        sum=sum+(num%10)
        num=num//10
    return sum
num=int(input("Enter any Number  : "))
sum=sumOfDigit(num)
print("Sum of Digit : ",sum)
Output

Enter any Number  : 2342

Sum of Digit :  11


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad