About 13,000,000 results
Open links in new tab
  1. Make object return float value python - Stack Overflow

    Dec 6, 2014 · And while you're at it, you can make float(obj) work by implementing the __float__ method. from __future__ import division class Fraction(object): def __init__(self, num, den): self.num, self.den = num, den # the built-in function float(obj) calls obj.__float__() def __float__(self): """float(self): Return a float approximating the fraction."""

  2. float() in Python - GeeksforGeeks

    May 10, 2023 · Python float () function is used to return a floating-point number from a number or a string representation of a numeric value. Example: Here is a simple example of the Python float () function which takes an integer as the parameter and returns its float value. Output: The float () function in Python has the following syntax. Syntax: float (x)

  3. Python Return Float From Function - Finxter

    Oct 23, 2022 · To return a float, you can use the built-in float() function or create your own function with an arbitrary simple or complex expression within the function body and put the result of this after the return keyword (e.g., return 10/3).

  4. How do I get a float result? (Python) - Stack Overflow

    Apr 30, 2016 · y=float(input("Please enter the width of your wall.")) a=float(input("Please enter the height of the obtruction.")) b=float(input("Please enter the width of the obtruction.")) coats = float(input("How many coats of paint would you like?")) print("You will need %d litres of paint." % (float(result))) Try this: stackoverflow.com/questions/1267869/…

  5. Python float () Function - W3Schools

    Definition and Usage The float() function converts the specified value into a floating point number.

  6. Python float () Function: Key Concepts [With Examples]

    Nov 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.

  7. The Python return Statement: Usage and Best Practices

    In this step-by-step tutorial, you'll learn how to use the Python return statement when writing functions. Additionally, you'll cover some good programming practices related to the use of return. With this knowledge, you'll be able to write readable, robust, and maintainable functions in …

  8. Returning function values as float Python 3.6.1 - Stack Overflow

    Jul 16, 2017 · return float(input("Enter the length of side A: ")) return float(input("Enter the length of side B: ")) return math.sqrt(a^2 + b^2) print('End of program!') If you're trying to use the power operator, you need to use ** instead. ^ has a completely different meaning in Python. It's the bitwise XOR operator.

  9. Python float () Function – Be on the Right Side of Change - Finxter

    Feb 4, 2021 · Python’s built-in float(value) function converts the argument value to a float number. For example, float('42') converts the string value '42' into the float number 42.0. A Python object to be converted into a float number.

  10. Python float ()

    Summary: in this tutorial, you’ll learn how to use Python float() to convert a number or a string to a floating point number. The float() accepts a string or an number, either an integer or a floating …

  11. Some results have been removed
Refresh