This blogs determine even and odd numbers between 1 to 25. Also displaying count for the number of even and odd numbers

We will use for loop to specify range between 1 to 25. This program is very simple. First of all create two variables even and odd that will store count with initial value of zero

even = 0

odd = 0

Using for loop and if statement to determine even and odd number. If the number is divided by 2 with 0 remainder than that number is even otherwise number is odd.

for num in range(1,25):

if num%2 == 0:

print('%d number is even'%num)

even = even +1

else:

print('%d number is odd'%num)

odd = odd + 1

At last, displaying data inside even and odd variables.

print('Total even numbers between 1 to 25:%d'%even)

print('Total odd numbers between 1 to 25:%d'%odd)

Output

```
1 number is odd
2 number is even
3 number is odd
4 number is even
5 number is odd
6 number is even
7 number is odd
8 number is even
9 number is odd
10 number is even
11 number is odd
12 number is even
13 number is odd
14 number is even
15 number is odd
16 number is even
17 number is odd
18 number is even
19 number is odd
20 number is even
21 number is odd
22 number is even
23 number is odd
24 number is even
Total even numbers between 1 to 25:12
Total odd numbers between 1 to 25:12
```

Complete Code

even = 0

odd = 0

for num in range(1,25):

if num%2 == 0:

print('%d number is even'%num)

even = even +1

else:

print('%d number is odd'%num)

odd = odd + 1

print('Total even numbers between 1 to 25:%d'%even)

print('Total odd numbers between 1 to 25:%d'%odd)

### Like this:

Like Loading...

*Related*