About 3,860,000 results
Open links in new tab
  1. python - How to convert a decimal number into fraction ... - Stack Overflow

    Mar 31, 2016 · If you are using Python 2.6 still, then Fraction() doesn't yet support passing in a float directly, but you can combine the two techniques above into: …

  2. How to Round Numbers in Python? - GeeksforGeeks

    Apr 30, 2025 · Python provides various methods to round numbers, depending on how we want to handle the precision or rounding behavior. In this article, we'll cover the most commonly used …

  3. fractions — Rational numbersPython 3.13.3 documentation

    2 days ago · The fractions module provides support for rational number arithmetic. A Fraction instance can be constructed from a pair of integers, from another rational number, or from a …

  4. How to Round Numbers in Python

    Dec 7, 2024 · You can round numbers to specific decimal places using Python’s round() function with a second argument. Different rounding strategies can be applied using Python’s decimal …

  5. How to Round a Number in Python: Truncation, Arithmetic, and More

    Mar 23, 2020 · As it turns out, there are a ton of ways to a round a number in Python. For instance, we could truncate the fraction altogether using a cast to int: int() . Of course, there …

  6. Python round() Function - W3Schools

    The round() function returns a floating point number that is a rounded version of the specified number, with the specified number of decimals. The default number of decimals is 0, meaning …

  7. python - Round number to nearest integer - Stack Overflow

    It is based on using the string representation, obtained with repr() (NOT str()!). It looks hacky but it was the only way I found to solve all the cases. It works with both Python2 and Python3. num …

  8. Rounding in Python: Choosing The Best Way - Medium

    Mar 15, 2024 · There is also a faster way to round a number in Python — to completely discard the fractional part. To do this, we need to convert a fraction to an integer using the built-in int()...

  9. Round numbers with round() and Decimal.quantize() in Python

    Jan 15, 2024 · This article explains how to round numbers (floating point numbers float and integers int) in Python.

  10. round() function in Python - GeeksforGeeks

    Aug 7, 2024 · The `round()` function in Python is used to round numbers. It takes two parameters: the number to be rounded and, optionally, the number of decimal places. If no decimal places …

Refresh