Answer:
Complete python code along with comments to explain the whole code is given below.
Python Code with Explanation:
# import random module to use randint function
import random
# counter variables to store the number of even and odd numbers
even = 0
odd = 0
# list to store randomly generated numbers
random_num=[]
# A for loop is used to generate 100 random numbers
for i in range(100):
# generate a random number from 0 to 100 and append it to the list
random_num.append(random.randint(0,100))
# check if ith number in the list is divisible by 2 then it is even
if random_num[i] % 2==0:
# add one to the even counter
even+=1
# if it is not even number then it must be an odd number
else:
# add one to the odd counter
odd+=1
# finally print the count number of even and odd numbers
print("Total Even Random Numbers are: ",even)
print("Total Odd Random Numbers are: ",odd)
Output:
Total Even Random Numbers are: 60
Total Odd Random Numbers are: 40
Total Even Random Numbers are: 54
Total Odd Random Numbers are: 46