Python Program To Take List Items at Run Time and Then Perform Sum of Even List Items
print("The Python program to find sum of list items:")
list1=list(map(int,input("Enter List numbers:").split()))
print("My list is:",list1)
sum=0
for i in list1:
sum=sum+i
print("The sum of my list items is:",sum)
Output:
The Python program to find sum of list items:
Enter List numbers:20 30 30
My list is: [20, 30, 30]
The sum of my list items is: 80
Program to Find Sum of Even Numbers from List
print("The Python program to find sum of even list items:")
list1=list(map(int,input("Enter List elements:").split()))
print("My list is:",list1)
sum=0
for i in list1:
if i%2==0:
print(i)
sum=sum+i
print("The sum of even list items is:",sum)
Output:
The Python program to find sum of even list items:
Enter List elements:1 2 3 4 5 6 7
My list is: [1, 2, 3, 4, 5, 6, 7]
2
4
6
The sum of even list items is: 12
0 टिप्पण्या
कृपया तुमच्या प्रियजनांना लेख शेअर करा आणि तुमचा अभिप्राय जरूर नोंदवा. 🙏 🙏