Scroll Down to See All▾
absaiterallanextanyasciibinboolbreakpointbytearraybytescallablechrclassmethodcompilecomplexdelattrdictdivmodenumerateevalexecfilterformatfrozensetgetattrglobalshasattrhashhelphexidinputintisinstanceissubclassiterlenlistlocalsmapmaxmemoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesortedstaticmethodstrsumsupertupletypevarszip__import__clear_(dict)clear_(list)clear_(set)copy_(dict)copy_(list)copy_(set)fromkeysgetitemskeyspop_(dict)pop_(list)pop_(set)popitemsetdefaultupdatevaluescount_(tuple)count_(list)count_(str)index_(tuple)index_(list)index_(str)adddifferencedifference_updatediscardintersectionintersection_updateisdisjointissubsetissupersetremove_(set)remove_(list)symmetric_differencesymmetric_difference_updateunionupdateclosefilenoflushisattyreadreadablereadlinereadlinesseekseekabletelltruncatewritablewritewritelinesappendextendinsertreversesortcapitalizecasefoldcenterencodeendswithexpandtabsfindformatisalnumisalphaisasciiisdecimalisdigitisidentifierislowerisnumericisprintableisspaceistitleisupperjoinljustlowerlstripmaketranspartitionreplacerfindrindexrjustrpartitionrsplitrstripsplitsplitlinesstartswithstripswapcasetitletranslateupperdirzfillFunction Details: float
Description
Converts a string or number to a floating point number.
Extended Description
The float() function converts a string or number to a floating point number. If no argument is given, it returns 0.0. The function can convert numeric strings, integers, and even special strings like 'nan' (Not a Number) and 'inf' (Infinity) to their float representations. It's commonly used for type conversion and ensuring numeric inputs are in float format.
Exceptions
- ValueError: If the argument is a string that cannot be converted to a float
- OverflowError: If the argument is outside the range of representable values for a float
Read More about float from Python Documentation
Function Signature
float(x: Union[str, Number] = 0.0) -> float
Module: builtins
Class: float
Parameters
x: A string or number to be converted to a float. If omitted, returns 0.0.
Parameter List
- x: Union[str, Number]
Return
Returns a floating point number representation of the input.
Return Type
float
Output
Explanation
This example shows basic usage of float() with different types of inputs.