In Python, round
can be used to round to n decimal digits. Now, round(0.229, 1)
gives 0.2
and round(0.251, 1)
gives 0.3
. Is there a way in Python, to round them both in one direction, say, to 0.2
? In other words, is there something analogous to floor
or ceil
for rounding to an integer, in the context of rounding to a certain number of decimal places?
Update: Accepting the solution based on decimal
because it throws light on such a feature available in Python. The solutions based on dividing (and later multiplying) by a multiple of 10 are good ones and straightforward to use.