About 135,000 results
Open links in new tab
  1. python - How to print a float variable using the - Stack Overflow

    I'm using Python 3.7.1 on Windows. When I print a float variable using the % formatting. only the natural part is printed. Here is an example: result_2 = 4.523529411764706 statement_2a = …

  2. Python, print all floats to 2 decimal places in output

    Jan 16, 2010 · If what you want is to have the print operation automatically change floats to only show 2 decimal places, consider writing a function to replace 'print'. For instance: def fp(*args): …

  3. python - Easy pretty printing of floats? - Stack Overflow

    I have a list of floats. If I simply print it, it shows up like this: [9.0, 0.052999999999999999, 0.032575399999999997, 0.010892799999999999, 0.055702500000000002, …

  4. python - How to display a float with two decimal places ... - Stack ...

    I have a function taking float arguments (generally integers or decimals with one significant digit), and I need to output the values in a string with two decimal places (5 → 5.00, 5.5 → 5.50, etc). …

  5. How to format a floating number to fixed width in Python

    >>> number = 12.34 >>> print(f"{number}") 12.34 >>> print(f"{number:10f}") 12.340000 >>> print(f"{number:10.4f}") 12.3400 The 10.4f after the colon : is the format specification , with 10 …

  6. Python print a float with a given number of digits

    Jun 8, 2018 · I would like to print them so that the have the same number of digits (sum of the integer and decimal parts) For example considering the two numbers: a = 12.123456 b = …

  7. python - How to print full precision of floating numbers - Stack …

    Sep 27, 2018 · UPDATE: In Python 3 str on a float is guaranteed to produce a string literal with full precision. This was not the case in Python 2. For instance str(1.0000000000000002) was …

  8. python - How to print a float variable along with a string in the …

    @Jesse I'm happy to hear you're learning about Python. =) I think you'll find that what Python does differently will make you rethink a lot of paradigms and ideas. (It certainly did for me …

  9. variables - Printing floating points in python - Stack Overflow

    May 12, 2014 · You are using %d for displaying a floating point number. You can try below methods for displaying floating point numbers with precision. Method 2 is preferred for python …

  10. python - Display a decimal in scientific notation - Stack Overflow

    Aug 2, 2011 · As an aside, despite the format % values syntax still being used even within the Python 3 standard library, I believe it's technically deprecated in Python 3, or at least not the …

Refresh