Python float() FunctionPython Functions


The float() function converts an integer into a floating-point number.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

print("hex(10):  ", hex(10))
print("hex(0):  ", hex(0))
print("hex(11):  ", hex(11))
print("hex(9):  ", hex(9))

Output:

hex(10):   0xa
hex(0):   0x0
hex(11):   0xb
hex(9):   0x9

Syntax

float(x)

Parameters

x — An integer.

Return Value

It returns a floating-point number.

© 2021 Programtips.org, all rights reserved. Privacy Policy | Contact Us