write a program in python to accept any 15 numbers and print the sum of even numbers only
Answers
Answered by
0
Code:
Explanation:
We create a list for the numbers that are going to be entered. A loop is initiated, that runs 15 times, obtaining 15 numbers from the user. As the numbers are being entered, they're being added to the list earlier created for the same, by the function. We then create a variable 's', that is going to represent the sum of the even numbers in the list. Another loop initiated, that traverses through the list and checks if the numbers are even or not, using a conditional statement. If they're even, they get added to 's'. The final output is printed in an appropriate statement.
Similar questions