Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Python (http://www.go4expert.com/forums/python/)
-   -   python help (http://www.go4expert.com/forums/python-help-t20868/)

msullivan3 4Feb2010 09:22

python help
 
trying to figure out a simple little function

Given a variable temps that refers to a list, all of whose elements refer to values of type float , representing temperature data, compute the average temperature and assign it to a variable named avg_temp . Besides temps and avg_temp , you may use two other variables -- k and total .

i currently have:

for k in range(len(temps)):
total += temps[k]

avg_temp = total / len(temps)

and I cannot figure out what is going and why this isnt working for me

msullivan3 4Feb2010 09:30

Re: python help
 
nevermind. never declared certain variables. feel free to delete or close this thread


All times are GMT +5.5. The time now is 02:35.