aList = [504, 483, 416, 358, 332, 275, 235, 189, 221, 132, 131, 213, 269, 262, 249, 245, 264, 313, 384, 268] aNewList = [ 0, 5, 11] #this function finds the largest item in a list, and returns it. def returnLargest( aList): currentLargest = aList[0] for item in aList: if (currentLargest < item): currentLargest = item return( currentLargest) #this function finds the smallest item in a list, and returns it. def returnSmallest( aList): currentSmallest = aList[0] for item in aList: if (currentSmallest > item): currentSmallest = item return( currentSmallest) # This function calculates the average of a non-empty list of # numbers. It has undefined results for lists of non-numbers and # empty lists. aValue = returnSmallest( aList) print "smallest is:", aValue def averageLight( aList): if (len(aList) < 1): print "Error: Empty list!" return None mySum = 0 for item in aList: mySum = mySum + item print "Sum is:", mySum print "number of items is:", len( aList) print "Average is:", float(mySum) / len(aList) #averageLight( anotherList)