Source code for gt_average
"""
This program finds all values greater than average,
then returns the number of such values, and the median of these values.
Pseudo code::
List of co2_levels is given
Find average value in the list
Find the list of values greater than average,
Put them in a list
Return the length of the list (number of such values)
Find the median and print
"""
co2_levels = [ 320.03, 322.16, 328.07, 333.91, 341.47,\
348.92, 357.29, 363.77, 371.51, 382.47, 392.95 ]
avg = float(sum(co2_levels))/len(co2_levels)
gtavg = []
for value in co2_levels:
if value > avg:
gtavg.append(value)
print "average is", avg
print "Values greater than average", gtavg
print "%d values greater than average" %(len(gtavg))
medianval = median(gtavg)
print "Median value", medianval