all Python 3Numbers & mathfunction
float.conjugate
as a number
Return the complex conjugate; for a float (a real number) it is the number itself.
Syntax
x.conjugate()
Conjugating a real number changes nothing, so you would not write this call in ordinary code: it exists for the shared numeric protocol alongside .real and .imag, letting a formula written for complex run on floats without type checks. The result stays a float — the method never promotes a number to complex; complex() does that.
Examples
print((3.5).conjugate()) # → 3.5
print((-1.0).conjugate()) # → -1.0
print(type((3.5).conjugate())) # → <class 'float'>
print((2.5).conjugate() == 2.5) # → True
print((3.5).imag) # → 0.0
print(complex(3.5).conjugate()) # → (3.5-0j)
See also
Open in the full glossarydocs.python.orgReport an inaccuracy