Empowering you to understand your world

Python Tutorials: How To Convert A Number To A Float

What Is A Float In Python?

In Python, a float is a floating point variable that facilitates the storage of decimal numbers.

How To Convert A Number To A Float In Python

You can convert a number or a string to a float in python using the ‘float()’ function as follows. The first line converts a string, and the second converts a numeral:

float("4.2")
float(4.2)
Subscribe to our newsletter
Get notified when new content is published