Code for Properties of a List in Python

An example that uses this code Compute The Average, Min, Max And Mode Of A List In Python.

def avg(list):

	sum = 0
	for elm in list:
		sum += elm
	return sum/(len(list)*1.0)
def min(list):
	min = list[0]
	for elm in list[1:]:
		if elm < min: 
			min = elm
	return min
def max(list):

	max = list[0]
	for elm in list[1:]:
		if elm > max: 
			max = elm
	return max
def mode(list):
	d = {}
	for elm in list:
			d[elm] += 1
			d[elm] = 1
	keys = d.keys()
	max = d[keys[0]]
	for key in keys[1:]:
		if d[key] > max:
			max = d[key]

	max_k = []		
	for key in keys:
		if d[key] == max:
	return max_k,max
def range_of_list(list):
	return max(list) - min(list)

def main():
	list = [3,4,1,20,102,3,5,67,39,10,1,4,34,1,6,107,99]
	print "The average element of the list is: " + str(avg(list))
	print "The minimum value in the list is: " + str(min(list))
	print "The maximum value in the list is: " + str(max(list))
	keys = mode(list)
	print "The mode of the list is: " + ','.join(map(str,keys[0])) + " with the mode of: " + str(keys[1])
	print "The range of the list is: " + str(range_of_list(list))
if __name__ == "__main__":