New to Python
Mon Mar 12 09:53:40 CET 2007
Alberto Vieira Ferreira Monteiro <albmont at centroin.com.br> writes:
> Hi, I am new to Python, how stupid can be the questions I ask?
Well, it's a matter of how you ask them, but anyway newcomers
are welcome here.
> For example, how can I add (mathematically) two tuples?
> x = (1,2)
> y = (3,4)
> How can I get z = (1 + 3, 2 + 4) ?
The simplest way is explicitly:
z = (x+y, x+y)
There's not a really direct way to do it. Tuples aren't vectors.
Python does support complex numbers if that's what you want:
x = 1+2j # Python uses "j" for sqrt(-1)
y = 3+4j
z = x + y
More information about the Python-list