Python Program To Print Sum of Even Data Elements
my_set=set(map(int,input("Enter set element:").split()))
print("The set elements are:",my_set)
sum=0
print("The even set elements are:",end=' ')
for i in my_set:
if isinstance(i,int):
if i%2==0:
print(i,end=' ')
sum=sum+i
print("\nThe sum of even data elements of set is:",sum,end=" ")
Output:
Enter set element:1 2 3 4 5 6 7 8 9 10
The set elements are: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
The even set elements are: 2 4 6 8 10
The sum of even data elements of set is: 30
0 टिप्पण्या
कृपया तुमच्या प्रियजनांना लेख शेअर करा आणि तुमचा अभिप्राय जरूर नोंदवा. 🙏 🙏