109k views
5 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 Diego Haz
by
4.8k points

1 Answer

6 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 Jukzi
by
4.5k points