Float is one of the basic built-in data types in Python, paired with int and diverse data types. The float function in Python’s standard library transforms an integer or a string of numbers into a float data type. When a string is regarded as valid for converting to a float, the following rules apply.
The string must only include integers.
Mathematical operators can also be applied between the numbers.
The string might be NaN or inf
White spaces at the start and finish are always ignored.
Examples for working of “float()”:
As an integer:
Floating type string: