I would like to write a specif rounding logic.
number = x
if x < 950:
# round number to and in steps of 50
elif x < 9000:
# round number to and in steps of 100
elif x < 100000:
# round number to and in steps of 250
else:
# round number to and in steps of 1000
This is my idea how it could work.
What I need for example, if x = 123 then the it should be rounded to 100. if x = 170 it should be rounded to 200, and then for example for x = 8568 it should round to 8600
round(8568/100)*100orround(170/50)*50?xalways an integer? Which direction should halfway-cases round (e.g.,825or1350)?170round to200rather than150?150is closer, so it's not clear to me what rule you're using here.