Python Random function
Question: 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


Answer: This is how you do it, assuming your original code is correct in other
respects:

    
    
    import random
    count = 0
    for x in range(20): 
         a=random.randint(1000,2000) 
         # b=(a>1500)// This is expected to give a boolean 
         # print b 
         if (a > 1500):
            count = count + 1
    
    print count
    

