1# Basic syntax:
2import math
3math.floor(larger_number / multiple) * multiple
4
5# Example usage:
6# Say you want to get the nearest multiple of 5 less than 29
7import math
8math.floor(29 / 5) * 5
9--> 25
10
11# Note, you can also do this with div if you don't want to import math
1229 // 5 * 5
13
14# Note, to get the nearest multiple of 5 greater than 29 run:
15math.ceil(29 / 5) * 5
16--> 30
1def rof(x): '''round up to multiple of 5'''
2 if x%5==4:
3 x+=1
4 elif x%5==3:
5 x+=2
6 print(x)
1#round up to multiple of 5 from both end
2def rof(x,y,z):
3 if x%5==4:
4 x+=1
5 elif x%5==1:
6 x-=1
7 elif x%5==2:
8 x-=2
9
10