[Tutor] doing maths on lists
cbeg at gmx.de
Mon Dec 20 12:28:42 CET 2010
I tried to put a float around my lists as well as around the sum but it didn't work.
Do I have to do some type casting around all items of the list?
-------- Original-Nachricht --------
> Datum: Mon, 20 Dec 2010 16:33:39 +0530
> Von: Nitin Pawar <nitinpawar432 at gmail.com>
> An: Chris Begert <cbeg at gmx.de>
> CC: tutor at python.org
> Betreff: Re: [Tutor] doing maths on lists
> you may want to do type casting whenever you have a float answer cause
> integer to float causes data loss
> On Mon, Dec 20, 2010 at 4:28 PM, Chris Begert <cbeg at gmx.de> wrote:
> > Bonjour
> > I have three lists with 65 float items and would like to do the
> > sum:
> > L0 = ([sum(L0A[i]*cos(L0B[i]+L0C[i]*JME) for i in range(0,64,1))])
> > So it just should do a sum across all the items in the list:
> > L0A*cos(L0B+L0C*JME)+ L0A*cos(L0B+L0C*JME)+...
> > + L0A*cos(L0B+L0C*JME)= some float number
> > However, I always get this error:
> > TypeError: can't multiply sequence by non-int of type 'float'
> > I looked it up and there seems to be some solution using either the
> > "for-in" command or the "map(int,...)" command but I just can't get it
> > work....
> > Any help will be very much appreciated :)
> > Greetings from Sydney
> > Chris
> > --
> > GRATIS! Movie-FLAT mit über 300 Videos.
> > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> Nitin Pawar
GRATIS! Movie-FLAT mit über 300 Videos.
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
More information about the Tutor