[Tutor] arrays, while loops

Deborah Knoll dknoll66 at hotmail.com
Sat Feb 18 19:35:17 CET 2012


Hi
I need some help with my program. I need to:
 
Inside a getNumbers() function:
Make an array that holds 7 elements - (got that done)
make sure the numbers entered are greater than 0 and less than 1001 (can't get this) - is there a way to write a "between" statment or an "or"??
 send the array to the aboveAverage () function
 
What I can't get to work is the between 0 and 1001, and also where to make the array entries integer (I get an error saying can't compare string and integer)
 
I also have to answer the three questions I have commented out at the end. I know this should be simple,  but the more I read and try things, the more confused I get.
 
Thanks for any suggestions!
 
 
 
Here is what I have so far:
 
amount = [0 for index in range (7)]
size = len (amount)
def getNumbers():
        for index in range (size):
                amount[index] = input ("Enter an amount: ")
        while amount[index] >0 or < 1001:
                return (amount[index])

 
##getNumbers()
##
##def aboveAverage():
##        total = 0.0
##
##        for value in amount:
##                total +=amount[index]
##        average = total/len(amount)
##        
##
##getNumbers()
##def printData():
##        
##print ("The numbers you entered from lowest to highest are: ")
##print ("The average number is: ")
##print ("You entered this many numbers above average: ")
##
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120218/4f83c314/attachment.html>


More information about the Tutor mailing list