[Tutor] Maths Operations on lists (update)

valhalla tireseas@onetel.com
Wed Jun 11 14:16:35 2003


Kalle Svensson, Michael Barrett & Alan Gauld:

Thank you each for your suggested solutions to the problem I presented=20
yesterday. I said that I would report back, which I am now doing:

1. Each of you answered my question clearly and directly, and that made t=
hings=20
really straightforward for me, and your responses were easy to follow.
2. The piece(s) that I was missing in resolving the problem was really ho=
w I=20
could (a) sum the contents of a list and then (b) divide that sum by the=20
len(list). I knew that I would divide it by the len of the list, since th=
at=20
way the list could be any length and it would disturb the operation.=20
3. My own attempts at solution came closest to the one Kalle proposed - i=
=2Ee.=20
assigning a 'third' variable the role of holding the sum, but I went abou=
t it=20
the wrong way. I used a 'for' loop to do the iteration but fouled it up, =
and=20
looking at Kalle's proposition realised where I went wrong.=20
4. Michael's proposition was also along the same kinds of lines, but with=
 the=20
added type declaration of float (i.e. %f).
5. However, I used Alan's proposal finally because (a) it pushed me beyon=
d my=20
comfort zone in that I hadn't even thought of that as a solution and (b)=20
because it is quite succinct. Also, due to my looking for list operations=
 I=20
wanted to use Alan's idea because it clearly is a list operator.

So, thank you guys for taking the trouble to suggest these solutions!!!

All the best

=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
||  Reg. Linux User: 313143 ||
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sign the Petition:
http://www.PetitionOnline.com/endtcpa1/