top of page
"Everything is related to everything else, but near things are more related than distant things"
Random Even Odd
The Python script generates 100 random numbers (in the range of 1-1000) and keeps a count of how many of those random numbers are even and how many are odd. Then prints the results to the screen as seen in the sample output below:

# Ehsan Momeni
from random import *
Even_counter=0 #counts even numbers
Odd_counter=0 #conts odd numbers
for i in range(1,101):
Num=randint(1,1000) #generatin random
if Num % 2 ==0:
Even_counter+=1
else:
Odd_counter+=1
print "Out of 100 random numbers, %d are even and %d are odd number"%(Even_counter,Odd_counter)
bottom of page