Basic python program to find sum of digits of a number using for loop. In this program we can execute sum of digits of a number for beginners to understand the programming concepts in python.
For Loop Definition in Python
In Python, a for loop is a control flow statement that is used to execute a set of statements repeatedly as long as the condition is met. An iterative statement is another name for this type of statement. A for loop is thus an iterative statement.
List Definition in Python
In Python, a list is a data structure that is a mutable (or changeable) ordered sequence of elements. A list’s items are the elements or values that make up the list. Lists are defined by values between square brackets [] in the same way that strings are defined by characters between quotes. This is basic python program on list for beginners. Here we have used the list to execute the python program to find sum of digits of a number using for loop
Python Program to Find Sum of Digits of a Number Using For Loop
total = 0
list1 = [15, 3, 37, 78, 13]
for ele in range(0, len(list1)):
total = total + list1[ele]
print("Sum of the Given List", total)
Output:
Sum of the Given List 146
Python Program to Check if an Element Exists in List
Python Program to Find the Length of a List
Python Program to Left Rotate the Elements of an Array
Python Program to Check Leap Year Using Function
Python Program to Swap First and Last Element of List
Python Program to Check Perfect Number Using While Loop
Python Program to Check Palindrome Number Using Functions
Python Program to Find Armstrong Number in an Interval Using While Loop