+ 1

Rounding In Python

Code: import math x = 5.6 y = round(x) print(y) z = round(x,-1) print(z) Output: 6 10 Could someone please explain what effect the -1 has? Because when I change x to 4.3 for example my outputs are 4 and 0.

3rd Dec 2019, 1:32 AM
PureLogicality
PureLogicality - avatar
1 Antwort
0
round(x,n) Where n rounds of to the value specified For eg round(80.23456, 2) : 80.23 it rounds off the first 2 digits after decimal
27th Oct 2022, 7:02 PM
Mridul Pramod
Mridul Pramod - avatar