Saturday, April 4, 2015

float() - Python Tutorial

float() built-in function in python



 


Float() Built-in Function In Python


The float() built-in function converts integers and strings to floating point numbers.  This basic function simply just changes the type of object to a floating point number type in Python.


Float() Syntax


float(argument)


The argument can be a integer or string.  You can also include a float but it will do nothing to the floating point number. If you call the float() function on a integer the when be convert to float which it will contain a decimal and a zero.


Float() Examples


#float examples

>>> float(1)
1.0
>>> float("6")
6.0
>>> float("5.6")
5.6

If you have any questions about the float() built-in function leave a comment below and we will assist you.


 



No comments:

Post a Comment