About 149 results
Open links in new tab
  1. 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 …

  2. Numbers in Python

    You can round a number to a given number of decimal places by passing a second argument to round(): Python >>> round ( 3.14159 , 3 ) 3.142 >>> round ( 2.71828 , 2 ) 2.72

  3. round () | Python’s Built-in Functions – Real Python

    The built-in round() function takes a numeric argument and returns it rounded to a specified number of decimal places. This rounding operation uses the round half-to-even strategy, which …

  4. How to Format Floats Within F-Strings in Python – Real Python

    If you want to round numbers to significant figures, you use the lowercase letter g in the format specifier. You can also use an uppercase G , but this automatically switches the format to …

  5. Rounding Numbers in Python

    How rounding affects data and which rounding strategy minimizes this effect; How to round numbers in NumPy arrays and pandas DataFrames; When to apply different rounding …

  6. Make Your First Python Game: Rock, Paper, Scissors!

    In this tutorial, you'll learn to program rock paper scissors in Python from scratch. You'll learn how to take in user input, make the computer choose a random action, determine a winner, and …

  7. Python Modulo in Practice: How to Use the % Operator

    In this tutorial, you'll learn about the Python modulo operator (%). You'll look at the mathematical concepts behind the modulo operation and how the modulo operator is used with Python's …

  8. Rounding Up (Video) - Real Python

    In this lesson, I’ll begin to explore the different ways of rounding, starting with rounding up To better understand why Python has chosen the algorithm it has for the built-in round() function, …

  9. Build a Dice-Rolling Application With Python – Real Python

    In this tutorial, you’ll learn how to create a Python dice roll simulator. The tutorial guides you through building a text-based user interface (TUI) application that simulates rolling dice using …

  10. The Python Square Root Function

    In this quick and practical tutorial, you'll learn what a square root is and how to calculate one in Python. You'll even see how you can use the Python square root function to solve a real-world …

Refresh