we know that Python round() function requires two arguments.
- First is the number to be rounded.
- And Second argument decides the number of decimal places to which it is rounded.
So to round the number to 2 decimals, give second argument as 2. If third digit after decimal point is greater than 5, then last digit is increased by 1 position .
>>> round(1.4756,2)
1.48
>>> round(1.3333,2)
1.33
Table of Contents
several ways to round decimal digits in python :
- Round() function use to rounds decimal places up and down. This makes 3.6578 into 3.66 and 6.62392 into 6.62.
- To round decimal places up we can to also use a custom function. i.e. 4.343 becomes 4.35.
- Similar to prev.round decimal places down we use a custom function. i.e. turns 1.348 into 1.34.
Python Code For Round To Two Decimals on Trinket :
Summary :
In this article we saw Python Code For Round To Two Decimals so about this section you have any query then free to ask me