Hi Python programmer, In this article, you will learn all about the Python round() built-in function that is used to return the rounded version of a specified number, with the specified number of decimals.
In the previous tutorial, we have seen lots of Python built-in functions along with examples.
Headings of Contents
Python round() function Introduction
Python round() function is a Python built-in function which means you don’t need to install it by using the Python pip command because it comes with Python default. The round () function is used to return the rounder version of a number with a specified number of decimals.
The syntax of round function in Python is:-
round function in Python take two arguments.
- number:- Number to be rounded.
- digits:- Optional, The number to decimals to use when a specified number is rounded. The default is 0.
The returns value of the round function in Python is the rounded version of the specified number.
Python round() function examples
Here we see the Python round function using an example.
Example: Using Python round() function
x = 12.233443 print(round(x, 2)) print(round(x, 3)) print(round(x, 4)) print(round(x, 5))
12.23 12.233 12.2334 12.23344
So, throughout this article, you have learned all about the Python round() function to return the rounded version of the specified number with a specified number of decimals. You have to remember one thing always, the round() function takes two arguments first is a number, and the second is also a number to be returned after the decimal and returns a floating point number.
If this article helped you please share and keep visiting for further python built-in functions tutorials.
Python built-in functions
For more information:- Click Here
Thanks for reading… ❤️❤️🙏🙏