How to Make a Float in "Python"

By Veronica Summers

Python is an open-source programming language used by beginners for its easy-to-read code and experts for its substantial libraries and ability to add modules from other programming languages such as C. When programming in Python, you may need to convert an integer or a string to a floating point number, or float. An example is when you need more accuracy in performing a calculation than is provided with the integer data type. Use the float command to convert a number to a floating point format.

Step 1

Open your Python interpreter.

Step 2

Type the following:numberInt = 123.45678float (numberInt)

Step 3

Press "Enter." Python returns:123.45677999999999In this example, Python converts the integer to a floating point numeral. For a numerical string, the code is the same. Consider the string example:numberEx = '123.45678'float (numberEx)Python converts the string to the floating point number "123.45677999999999."