+ 1
hi there! can somebody explain the round() function?
e.g : x = round(1.356, 2) print(×)
5 Respostas
+ 3
The optional second argument in the round function is for precision after the decimal point. So round(1.356, 2) rounds 1.356 to 2 decimal places. That would be 1.36, as among the numbers that have two digits after decimal, it is the closest one to 1.356.
Btw Rhyr Core, unfortunately you chose a bad example. Python uses the "round half to even" convention, which means 2.5 is rounded down to 2, even though 3.5 is rounded up to 4.
+ 2
Say you owe a grocery store owner 129.75 pesos, but you don't have any centavos to pay the exact change. So you round it and pay them 130 pesos instead.
+ 1
The round() method rounds a number to the nearest integer.
Note: 2.49 will be rounded down (2), and 2.5 will be rounded up (3)
+ 1
thanks for share
0
in the real live how can a aplicate it??