Re: [Tutor] python lists/nested lists

2013-04-13 Thread Steven D'Aprano
On 14/04/13 06:53, Soliman, Yasmin wrote: How can I calculate the average of a list of numbers (eg [2,5,8,7,3] ) and then subtract the avg from the original numbers in the list and print? You calculate the average by summing the list, then dividing by the number of items. To sum a list of n

Re: [Tutor] python lists/nested lists

2013-04-13 Thread Alan Gauld
On 13/04/13 21:53, Soliman, Yasmin wrote: How can I calculate the average of a list of numbers (eg [2,5,8,7,3] ) > and then subtract the avg from the original numbers > in the list and print? This sounds like homework which we don;t do for you. However to calculate the average take the sum and

Re: [Tutor] python lists/nested lists

2013-04-13 Thread Mark Lawrence
On 13/04/2013 21:53, Soliman, Yasmin wrote: How can I calculate the average of a list of numbers (eg [2,5,8,7,3] ) and then subtract the avg from the original numbers in the list and print? lst = [2,5,8,7,3] avg = sum(lst) / len(lst) print(avg) for n in lst: print(n - avg) Also, if I ha

[Tutor] python lists/nested lists

2013-04-13 Thread Soliman, Yasmin
How can I calculate the average of a list of numbers (eg [2,5,8,7,3] ) and then subtract the avg from the original numbers in the list and print? Also, if I have a nested list: sick_patients=[['Sam', 'M', 65, 'chest pain', 101.6], [['Sarah', 'F', 73, 'dizziness', 98.6], [['Susie', 'F', 34, 'he