# Python Exercise: Count the number of even and odd numbers from a series of numbers

## Python Conditional: Exercise-6 with Solution

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

**Pictorial Presentation of Even Numbers:**

**Pictorial Presentation of Odd Numbers:**

**Sample Solution:**

**Python Code:**

```
numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9) # 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)
```

Sample Output:

Number of even numbers : 4 Number of odd numbers : 5

**Flowchart: **

**Even Numbers between 1 to 100:**

**Odd Numbers between 1 to 100:**

## Visualize Python code execution:

The following tool visualize what the computer is doing step-by-step as it executes the said program:

**Python Code Editor: **

**Have another way to solve this solution? Contribute your code (and comments) through Disqus.**

**Previous:** Write a Python program that accepts a word from the user and reverse it.

**Next:** Write a Python program that prints each item and its corresponding type from the following list.

**What is the difficulty level of this exercise?**

Test your Programming skills with w3resource's quiz.

## Python: Tips of the Day

**Chain Operators**

You can chain comparison operators in Python as following: n = 10 result = 1 < n < 20

distance = 200 checker = 100 < distance < 350 print(checker)

Output:

True

**Exercises: Weekly Top 16 Most Popular Topics**- SQL Exercises, Practice, Solution - JOINS
- SQL Exercises, Practice, Solution - SUBQUERIES
- JavaScript basic - Exercises, Practice, Solution
- Java Array: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : Conditional Statement
- HR Database - SORT FILTER: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : String
- Python Data Types: Dictionary - Exercises, Practice, Solution
- Python Programming Puzzles - Exercises, Practice, Solution
- C++ Array: Exercises, Practice, Solution
- JavaScript conditional statements and loops - Exercises, Practice, Solution
- C# Sharp Basic Algorithm: Exercises, Practice, Solution
- Python Lambda - Exercises, Practice, Solution
- Python Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- JavaScript: HTML Form Validation