Q:

Write a Python program to count the number of even and odd numbers from a series of numbers

0

Write a Python program to count the number of even and odd numbers from a series of numbers

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used python 3.7 compiler for debugging purpose.

numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) # Declaring the tuple
count_odd = 0
count_even = 0
for x in numbers:
        if not x % 2:
             count_even+=1
        else:
             count_odd+=1
print("Number of even numbers :",count_even)
print("Number of odd numbers :",count_odd)

Result:

Number of even numbers : 5

Number of odd numbers : 5

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a Python program that accepts a word from th... >>