Built-in Functions
float()
Convert a value to a decimal number.
float(number=0.0)
float() creates a number that can hold a decimal point. It can convert suitable numbers and numeric strings.
Arguments
Parameters
| Name | Description |
|---|---|
| number | A number or numeric string to convert. If omitted, it defaults to 0.0. |
Result
Returns
A floating-point number.
Run it
Try it
Run it and change it
text = "3.5" number = float(text) print(number + 0.5)
Output
Press Run to see what it prints.