Quick question.....

Batista, Facundo FBatista at uniFON.com.ar
Wed Jan 14 22:15:34 CET 2004


featherstone80 wrote:

#- numberlist = [10, 2, 5, 7, 3, 46, 4, 5, 87, 5]
#- 
#- How would I get the total, and how would I get the average?


Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
...
>>> numberlist = [10, 2, 5, 7, 3, 46, 4, 5, 87, 5]
>>> sum(numberlist)
174
>>> len(numberlist)
10
>>> sum(numberlist)/len(numberlist)
17
>>> from __future__ import division
>>> sum(numberlist)/len(numberlist)
17.399999999999999

.	Facundo




More information about the Python-list mailing list