Tech Study

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

Introduction

Write a Python program to count the number of even and odd numbers from a series of numbers. 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

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

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

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more