A float is a floating point number which is a computers representation of a real number (where an integer can only hold whole numbers, real numbers can also be decimals etc). All the float function does is convert what you give it into a floating point number. e.g float(10) will return 10.0 float("10") will also return 10.0 float("10.5") will return 10.5 Answer from Neexusiv on reddit.com
🌐
W3Schools
w3schools.com › python › ref_func_float.asp
Python float() Function
The float() function converts the specified value into a floating point number. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com
🌐
GeeksforGeeks
geeksforgeeks.org › python › float-in-python
float() in Python - GeeksforGeeks
September 18, 2025 - In Python, the float() function is used to convert numbers or numeric strings into floating-point numbers. A floating-point number is simply a number with a decimal point (for example, 3.14, -0.5, or 10.0).
Discussions

What does the float function do?
A float is a floating point number which is a computers representation of a real number (where an integer can only hold whole numbers, real numbers can also be decimals etc). All the float function does is convert what you give it into a floating point number. e.g float(10) will return 10.0 float("10") will also return 10.0 float("10.5") will return 10.5 More on reddit.com
🌐 r/learnpython
9
3
September 9, 2020
python - How does "-float" works? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I have just seen a code in my homework. It says result=-float("inf"). I don't really understand what -float means. ... float(x) returns the numeric value of x, which you can then use in conjunction with arithmetic operations, such as +, -, * and /. ... float(...) is a method in python ... More on stackoverflow.com
🌐 stackoverflow.com
Beginners Question Float
Hi, i’m very new to python and have a question about floating points. This is my script: num1 = input() operator = input() num2 = input() if operator == “-”: result = float(num1) - float(num2) elif operator == “+”: result = float(num1) + float(num2) elif operator == “*”: result ... More on discuss.python.org
🌐 discuss.python.org
0
0
August 3, 2021
Float and int function
float() and int() are mainly use to convert strings to numbers. They actually create a number from the strings. int() is also often use to create an integer number from a float number. A classic example is when you ask the user for a number. The input function always returns a string of character. To perform calculation you need a number (int or float). So you must create a number from that string. As in: string_number = input("Enter temperature in °F (integer): ") temp_far = int(string_number) temp_cel = (temp_far-32) * (5/9) # the result here is a float print("Temperature in celsius (float)", temp_cel) temp_cel_int = int(temp_cel) # creates an integer number from the float print("Temperature in Celsius (integer)", temp_cel_int) Using float on strings from math import radians angle_string = input("Enter a precise angle in degrees with decimal: ") angle_float = float(angle_string) radians_float = radians(angle_float) print("That angle in degrees is",radians_float,"in radians") More on reddit.com
🌐 r/learnpython
10
5
March 25, 2023
🌐
Programiz
programiz.com › python-programming › methods › built-in › float
Python float()
Created with over a decade of experience. ... Created with over a decade of experience and thousands of feedback. ... Try Programiz PRO! ... Become a certified Python programmer. Try Programiz PRO! ... The float() method returns a floating point number from a number or a string.
🌐
Built In
builtin.com › data-science › how-to-use-make-float-in-python
How to Use Float in Python (With Sample Code!) | Built In
This quick how-to will introduce you to the Python float function and show you how you can create them yourself.
🌐
Mimo
mimo.org › glossary › python › float
Mimo: The coding platform you need to learn Web Development, Python, and more.
Created with a Decimal or Division: You create a float by including a . in a number (e.g., 1.0) or as the result of a standard division operation (e.g., 10 / 5 results in 2.0). Use float() for Conversion: The float() function can be used to convert other data types, like integers or compatible ...
🌐
Python documentation
docs.python.org › 3 › tutorial › floatingpoint.html
15. Floating-Point Arithmetic: Issues and Limitations — Python 3.14.3 documentation
On most machines today, floats are approximated using a binary fraction with the numerator using the first 53 bits starting with the most significant bit and with the denominator as a power of two. In the case of 1/10, the binary fraction is 3602879701896397 / 2 ** 55 which is close to but not exactly equal to the true value of 1/10. Many users are not aware of the approximation because of the way values are displayed.
🌐
Simplilearn
simplilearn.com › home › resources › software development › python float() function: key concepts [with examples]
Python float() Function: Key Concepts [With Examples]
November 27, 2024 - Learn how the float() function in Python converts a specified value into a floating point number. Syntax: float(value). A key function for numeric conversions.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
Find elsewhere
🌐
Emeritus
emeritus.org › home › blog › coding › what is a float in python and how does it benefit programmers
What is a Float in Python and How Does it Benefit Programmers
August 12, 2025 - Here, value is a number or a string that you want to convert into a decimal. So, when you want to use the float function to convert integers into floating numbers, you must type float and add the numerical value.
🌐
Career Karma
careerkarma.com › blog › python › python float: a step-by-step guide
Python Float: A Step-By-Step Guide | Career Karma
December 1, 2023 - Here’s the syntax for the float() ... its default value is 0.0. You can use the float() method in Python to convert an integer to a floating-point number....
Top answer
1 of 5
9
A float is a floating point number which is a computers representation of a real number (where an integer can only hold whole numbers, real numbers can also be decimals etc). All the float function does is convert what you give it into a floating point number. e.g float(10) will return 10.0 float("10") will also return 10.0 float("10.5") will return 10.5
2 of 5
3
On the surface, it can convert integers and numeric string literals into floating-point numbers which can be used to represent any real numbers instead of just whole numbers. That said, despite appearances, float is technically the class itself and not a function. That's why you can use the "function" when type hinting or checking if a value is a float with isinstance. first = float(3) second = float("7.5") stuff: float = 5.74 isinstance(first, float) Of course, the same goes for bool, str, int, list, tuple and dict. All classes. "But why do they look like functions? Aren't classes supposed to start with capital letters?" Excellent question. Basically, the built-ins were made exceptions to the rule as it's easier for beginners to understand them as functions that can change the type of objects; string to integer, string to list, and so on. They'll later learn that they're actually far more flexible than functions. Most classes outside of __builtins__ do use the proper naming convention, like pathlib.Path, as they're not the things beginners are expected to see when they start out. And there could be other reasons for the lowercase names, this is just my conjecture.
🌐
Snakify
snakify.org › integer and float numbers
Integer and float numbers - Learn Python 3 - Snakify
The mass of one molecule of the water is 2.99·10-23, or 2.99e-23 in Python. One can cast float objects to int objects by discarding the fraction part using the int() function.
🌐
Codecademy
codecademy.com › docs › python › built-in functions › float()
Python | Built-in Functions | float() | Codecademy
June 18, 2025 - Both return the same result (42.0), but the conversion process differs. float(42) converts an integer to float, while float("42") parses a string representation and converts it to float. ... Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
🌐
W3Schools
w3schools.com › python › gloss_python_float.asp
Python Float
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... Float, or "floating point number" is a number, positive or negative, containing one or more decimals. ... Float can also be scientific numbers with an "e" to indicate the power of 10. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com
🌐
Stack Overflow
stackoverflow.com › questions › 71414328 › how-does-float-works
python - How does "-float" works? - Stack Overflow
... float(x) returns the numeric value of x, which you can then use in conjunction with arithmetic operations, such as +, -, * and /. ... float(...) is a method in python to convert an integer to a floating-point (i.e.
🌐
Python Land
python.land › home › python data types › python float: working with floating-point numbers
Python Float: Working With Floating-Point Numbers • Tutorial
September 16, 2025 - The floor function rounds a float down to the nearest integer while the ceil function rounds a float up to the nearest integer. Here’s an example of how you can import and use these functions:
🌐
Tutorialspoint
tutorialspoint.com › python › python-float-function.htm
Python float() Function
We create the "numeric_part" variable using a list comprehension that filters out non-numeric characters, resulting in a string with only digits "25". Finally, we use the float() function to convert this string into a floating-point number
🌐
Real Python
realpython.com › ref › builtin-types › float
float | Python’s Built-in Data Types – Real Python
You can create floats using literals, the float() constructor, or by converting strings or other numeric types: ... Consider a scenario where you need to calculate the area of a circle with a given radius using the formula area = π * radius^2.
🌐
Python.org
discuss.python.org › python help
Beginners Question Float - Python Help - Discussions on Python.org
August 3, 2021 - Hi, i’m very new to python and have a question about floating points. This is my script: num1 = input() operator = input() num2 = input() if operator == “-”: result = float(num1) - float(num2) elif operator == “+”: result = float(num1) + float(num2) elif operator == “*”: result = float(num1) * float(num2) elif operator == “/”: result = float(num1) / float(num2) print(result) when i run this script and enter 12.2 as num1 and multiply num1 with 3 as num2 i get 36.599999999999994 We...
🌐
Udacity
udacity.com › blog › 2025 › 03 › floating-point-numbers-in-python-what-they-are-and-how-to-use-them.html
Floating Point Numbers in Python: What They Are and How to Use Them | Udacity
March 10, 2025 - The .2f tells Python to show exactly two decimal places, the .1% converts the number to a percentage with one decimal place and the >10 and <10 create spaces for aligning numbers, which is especially helpful when creating reports or displaying data in columns within a table. When comparing floating-point numbers it’s better to avoid using the == operator directly as it’s likely to create precision issues. Instead, it’s usually better to use Python’s math.isclose() function, which allows us to determine if two numbers are “close enough”.
🌐
Reddit
reddit.com › r/learnpython › float and int function
r/learnpython on Reddit: Float and int function
March 25, 2023 -

Hello, please can someone explain to me when to use the float and int functions?

I mean should I use float when I am strictly dealing with decimal numbers, or when I want to convert whole numbers to decimal numbers?

pythonlearner

Top answer
1 of 4
5
float() and int() are mainly use to convert strings to numbers. They actually create a number from the strings. int() is also often use to create an integer number from a float number. A classic example is when you ask the user for a number. The input function always returns a string of character. To perform calculation you need a number (int or float). So you must create a number from that string. As in: string_number = input("Enter temperature in °F (integer): ") temp_far = int(string_number) temp_cel = (temp_far-32) * (5/9) # the result here is a float print("Temperature in celsius (float)", temp_cel) temp_cel_int = int(temp_cel) # creates an integer number from the float print("Temperature in Celsius (integer)", temp_cel_int) Using float on strings from math import radians angle_string = input("Enter a precise angle in degrees with decimal: ") angle_float = float(angle_string) radians_float = radians(angle_float) print("That angle in degrees is",radians_float,"in radians")
2 of 4
1
For string conversion, use the one appropriate to the string you're trying to convert. If you care about exact equality, don't use floats. Use integers, or maybe the Decimal class. If you want to know if floats are equal ish, keep in mind that the ish is always there. Use something like math.isclose to make such checks. There is rarely (almost never?) any need to explicitly convert integers to floats (unless you're doing something with numpy or similar). Integers will be automatically treated as floats during division (NOTE: different in some other languages), multiplication, etc. If you want to convert a float to integer, you can do that via int(2.3), but keep in mind how it rounds. There are other rounding functions that may or may not be more helpful (math.ceil, math.floor, round).