top of page

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)

google_scholar1-300x150.png
ResearchGate.png
Ehsan Momeni ORCID GIS Remote Sensing Ur
Ehsan Momeni LinkedIn GIS Remote Sensing
ncbi-300x150.png
academia.png

(Information on this website may not be up to date)

bottom of page