dimanche 3 avril 2016

Python Random function

Write a program to create an array of random numbers between 1000 to 2000 and count the number of values that are higher than 1500.

I've kind of have the understanding of setting the range, but not counting the number of returns.

What I have is this:

import random
for x in range(20): 
     a=random.randint(1000,2000) 
     b=(a>1500) 
     print b 
print 

this simply returns Trues or Falses, I need to know the total number of numbers over 1500 not if they are or aren't Thanks




Aucun commentaire:

Enregistrer un commentaire