calculation on lists

Vlastimil Brom vlastimil.brom at gmail.com
Wed Dec 19 18:24:11 CET 2012


2012/12/19 loïc Lauréote <laureote-loic at hotmail.fr>:
> hi,
> I
>  have a question,
> is there a tool to calculate on list ?
>
> something like :
>
>>a= [1,1,1,1]
>>b = [5,9,8,4]
>>c = a+b*a
>>print c
>>[6,10,9,5]
>
> Thx
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Hi,
I guess, if you are interested in effective and more complex matrix
computations, you might have a look at numpy:
http://www.numpy.org/
Is the following the result you expect? (it seems so, based on the
(added) output of your posted code, but its incompatible with the
example in the first post).

>>> import numpy
>>> a=numpy.array([4,5])
>>> b=numpy.array([6,7])
>>> b*b+a
array([40, 54])
>>>

hth,
  vbr



More information about the Python-list mailing list