Programming Examples

Python program to accept a integer number and find its sum of digit


Write a program to accept a integer number from user and find its sum of digit.

Sample 1:

Input : 123

Output : Sum of Digit : 6

Sample 2:

Input : 1234

Output : Sum of Digit : 10

Solution

num=int(input("Enter any Number : "))
sum=0
while num>0:
    digit=num%10
    sum=sum+digit
    num=num//10
print("Sum of Digit : ",sum)
▶ RUN

Output/ Explanation:

Enter any Number : 123

Sum of Digit :  6

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad