float()

float() returns floating point number by taking string or integer as input .

Here are some examples with different type of input numbers
print(float())       # 0.0 
print(float(5))      # 5.0
print(float("34.5")) # 34.5

String inputs

print(float("  45.8 ")) # 45.8
print(float("InF"))     # inf
print(float("NaN"))     #nan
print(float("Infinity"))#inf
We will get error message based on input
print(float('abc45'))
Output
ValueError: could not convert string to float: 'abc45'

Data type

We can check type of data by using type(). Here we have used one float number.
print(type(4.5)) # <class 'float'>
bin() int() complex()


plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer