# Python program to sum all the digits of an input number

## Python program to sum all the digits of an input number

In this tutorial, we are going to learn how to sum all the digits of an input number using a Python program, this kind of simple problem can be asked in CBSE class XI / XII “Computer Science with Python” Examination.

Environment used :

• OS : Linux
• Python Version : Python 3.6.9
• Text Editor : Atom ( you can use Notepad, Notepad++, Kate , Geany, IDLE …)

Lets move to our program  how to sum all the digits of an input number using a Python , for this we have to create a file named  addDigit.py with code given below, now open terminal /cmd, use CD command to go there and run

for Windows user : python addDigit.py

```# Programe : how to sum all the digits of an input number
no = int(input("Enter a Positive Number: "))
result = 0
noORG = no

while no > 0:
rem = no % 10
result = result + rem
no = int(no/10)

print("Sum of all digits of no. ", noORG, "is: ", result)
```

Screen shot of Out put : 5 1 vote
Article Rating
Subscribe
Notify of This site uses Akismet to reduce spam. Learn how your comment data is processed.