I'm not a Python expert by any stretch but I've learned some basics. You can refer to the documentation on the list
object here:
http://docs.python.org/2/library/functions.html#max
list
objects in python allow a min()
and max()
function. You can call these even before you sort the list, for example:
print min(marklist)
or print max(marklist)
.
Since you've already sorted the list to do your median calculation, you could also just retrieve the first and last item in the list, as the lowest & highest marks, respectively:
print marklist[0] #prints the first/0-index position in the list
And likewise the maximum value, since python supports reverse-indexing of list objects:
print marklist[-1] #prints the last position in the list
I tested it with this simple code:
marklist=[]
marklist=[10,13,99,4,3,5,1,0,22,11,6,5,38]
print min(marklist),max(marklist)
marklist.sort()
print marklist[0],marklist[-1]