Python Program to Calculate Sum of Digits

Python Program to Calculate Sum of Digits

To get sum of each digits in Python program here we used relational operator for entering in loop and print function for showing result .

Sum of Digits in Python :



Number = int(input("Please Enter any Number : ")) Sum = 0 while(Number > 0): Reminder = Number % 10 Sum = Sum + Reminder Number = Number //10 print("Sum of the digits of Given Number = %d" %Sum)

Output :