Write definition of a method Even Sum(NUMBERS) to add those values in the list of NUMBERS, which are even.

 

Answer:

def methoodEvenSum (NUMBERS):

    sum= 0

    for i in range (len(NUMBERS)):

        if NUMBERS[i]% 2 == 0 :

            sum=sum+NUMBERS[i]

    print(sum)

Question 2-Write definition of a method - Teachoo.JPG

Remove Ads

Transcript

Question 2 Write definition of a method EvenSum(NUMBERS) to add those values in the list of NUMBERS, which are even. defining a function to calculate the sum of even numbers For loop which iterates from 0 to the length of the list If the number is even, then it is added to the sum assigning the variable ‘sum’ the value 0 Checking if the number is divisible by 2

Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh is an IIT Kanpur graduate and has been teaching for 16+ years. At Teachoo, he breaks down Maths, Science and Computer Science into simple steps so students understand concepts deeply and score with confidence.

Many students prefer Teachoo Black for a smooth, ad-free learning experience.