Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products.

Python 3.10 is now available in preview.


Convert a string or number to a floating point number, if possible.

Inherits From: expected_type

imag the imaginary part of a complex number
real the real part of a complex number



Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original float and with a positive denominator.

Raise OverflowError on infinities and a ValueError on NaNs.

>>> (10.0).as_integer_ratio()
(10, 1)
>>> (0.0).as_integer_ratio()
(0, 1)
>>> (-.25).as_integer_ratio()
(-1, 4)


Return self, the complex conjugate of any float.


Create a floating-point number from a hexadecimal string.

>>> float.fromhex('0x1.ffffp10')
>>> float.fromhex('-0x1p-1074')


Return a hexadecimal representation of a floating-point number.

>>> (-0.1).hex()
>>> 3.14159.hex()


Return True if the float is an integer.




Return self+value.


self != 0


Return self==value.


Return self//value.


Return self>=value.


Return self>value.


Return self<=value.


Return self<value.


Return self%value.


Return self*value.


Return self!=value.






Return pow(self, value, mod).


Return value+self.


Return value//self.


Return value%self.


Return value*self.


Return pow(value, self, mod).


Return value-self.


Return value/self.


Return self-value.


Return self/value.