Home » float() in Python | Python float() Function with Examples

float() in Python | Python float() Function with Examples

by Online Tutorials Library

Python float() Function

The python float() function returns a floating point number from a number or string.

Signature

Parameters

value– It can be a number or string that converts into a floating point number.

Return

It returns a floating point number.

Python float() Function Example 1

The below example shows the working of float():

Output:

8.0  7.19  -24.17  -17.15  ValueError: could not convert string to float: 'xyz'  

Explanation: In the above example, a number and a string value is being converted into a floating point number.


Next TopicPython Functions

You may also like