Problem 1.3

Product of Even Numbers

Compute the product of even numbers among the list of numbers mentioned on the top of the program and print the result.

If you can if a number n is even or not by checking n % 2 == 0. For example:

n = 10
if n % 2 == 0:
    print("n is even")
else:
    print("n is odd")

Solution

# Do not change this line
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# Compute the product of even numbers among the list of numbers
# mentioned above and print the result.
# Your code below this line

result = 1
for n in numbers:
    if n % 2 == 0:
        result *= n

print(result)