Python Float() function
Published February 15, 2022In programming, multiple data types are used to store values. The type of data defines the value that will be stored. Numbers, for example, are stored as either integers or floats. Floats are used to store decimals, whereas integers are used to store numbers but not decimals.
In this post, we'll look at how to use Python's float () function to convert an integer to a floating value number.
Converting Integer into Float
In Python, you can convert a number stored in the form of an integer into a floating-point number using the float() function. The float () method is a Python function that converts an integer to a floating-point value.
Let's have a look at the float () method's syntax.
Syntax
The float() function has the following syntax:
float(value),
where value is the integer value that will be converted into a float
Example
In this example, we will convert an integer to a floating point value.
integer= 200 float_number = float(integer) print(float_number) |
Output
200.0 |
Article Contributed By :
|
|
|
|
341 Views |