Complex number calculation

Complex number absolute value

Use abs(z) to get its magnitude (as a float) or z.real to get its real part.


a=1.5+0.5j

print a.real
print abs(a) 

The code above generates the following result.

Multiply


print (3+1j)*3#  www .  j av  a 2  s .  c  om

print (1+2j)/(1+1j)
print 1j * 1J
print 2 + 1j * 3

The code above generates the following result.





















Home »
  Python »
    Data Types »




Data Types
String
String Format
Tuple
List
Set
Dictionary