Liczby Zespolone Python
# complex number
x = -5.79829066331+4.55640490659j
# parts
r = x.real # float
i = x.imag # float
# tuple, not complex number
y = (x.real, x.imag)
# complex number again
a = complex(r, i)
b = r + i * 1j
# operations
c = a + b
d = a * b
e = 1j * 1j # -1
f = abs(x) # distance - float
g = x.conjugate()
import cmath # not `math`
h = cmath.sin(x)
print('x:', x, type(x))
print('r:', r, type(r))
print('i:', i, type(i))
print('y:', y, type(y))
print('a:', a, type(a))
print('b:', b, type(b))
print('c:', c, type(c))
print('d:', d, type(d))
print('e:', e, type(e))
print('f:', f, type(f))
print('g:', g, type(g))
print('h:', h, type(h))
Copy To Clipboad
Graceful Gecko