mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
23 lines
435 B
Python
23 lines
435 B
Python
from cmath import isclose, sqrt
|
|
|
|
assert 1+2j == complex(1, 2) == 2j+1
|
|
|
|
assert isclose(1+2j + 3+4j, 4+6j)
|
|
|
|
assert isclose(1+2j - 3+4j, -2+6j)
|
|
|
|
assert (1+2j).real == 1
|
|
assert (1+2j).imag == 2
|
|
|
|
assert isclose((1+2j)*(3+4j), -5+10j)
|
|
assert isclose((1+2j)*3, 3+6j)
|
|
|
|
assert isclose((1+2j)**2, -3+4j)
|
|
|
|
assert (1+2j).conjugate() == 1-2j
|
|
|
|
res = sqrt(1+2j)
|
|
assert isclose(res, 1.272019649514069+0.7861513777574233j)
|
|
|
|
assert {1+2j: 1}[1+2j] == 1
|