Python Glossary Русский

all Python 3Numbers & mathfunction

int.conjugate

as a number

Return the complex conjugate; for an integer (a real number) it is the number itself.

Syntax

n.conjugate()

For an integer it returns the number itself, since the imaginary part is zero. The method exists for the shared numeric interface: a function calling x.conjugate() works the same for int, float, Fraction and complex without a type check. For bool it returns an int: True.conjugate() gives 1.

Examples

print((5).conjugate())   # → 5
print((-3).conjugate())  # → -3
print((0).conjugate())   # → 0
print((5).real, (5).imag)  # → 5 0
print((2 + 3j).conjugate())  # → (2-3j)
print([n.conjugate() for n in [1, -2, 2j]])  # → [1, -2, -2j]

See also

Open in the full glossarydocs.python.orgReport an inaccuracy