[Tutor] abs(z)

Jacques xxjac88xx at comcast.net
Sat Dec 6 17:11:43 EST 2003


>>> a=3.0+4.0j
>>> a.real
3.0
>>> a.imag
4.0
>>> abs(a)  # sqrt(a.real**2 + a.imag**2)
5.0
>>>

i understand why a.real = 3
and why a.imag = 4
but abs(a) MAKES NO SENSE...
im very good in math when i lookd at it i figured in # sqrt(a.real**2 + a.imag**2) the "**" must equal half AKA .5
but then i tried
>>> a=1.5+2j
>>> a.real
1.5
>>> a.imag
2.0
>>> abs(a) # sqrt(a.real**2 + a.imag**2)
2.5



2.5 makes no sense???
also what does sqrt stand for?
and correct me if im wrong but comment text after hash on same physical line doesn't do anythin to the program??



>>> a=3.5+5.0j
>>> a.real
3.5
>>> a.imag
5.0
>>> abs(a) # sqrt(a.real**2 + a.imag**2)
6.103277807866851


what is up with all those decimal point numbers?? 
it looks like anythin wit a floatin point AKA number after decimal point stays the same BUT
anythin witout a decimal point number or zero is divided by 2 plus the other number # if the other number has a decimal point in it.
Can someone please explain this whole thing better to me?





More information about the Tutor mailing list