336,947 views
13 votes
13 votes
Write a program that generates 100 random numbers and keeps a count of how many of those random numbers are even and how many of them are odd.

User Hitesh Hadia
by
2.7k points

1 Answer

17 votes
17 votes

Answer:

import random

numbers = []

even = 0

odd = 0

for i in range(100):

numbers.append(random.randint(1, 200))

for i in range(100):

if numbers[i] % 2 == 0:

even += 1

else:

odd += 1

print("Even:", even)

print("Odd:", odd)

Step-by-step explanation:

Gg ez.

User AxFab
by
2.7k points