remainder(x , y) Return remainder of x with respect to y.
remainder(n)
Example
import math
print(math.remainder(12,7)) # -2.0
print(math.remainder(12,5)) # 2.0
import math
print(math.remainder(13,7)) # -1.0
Using for loop
for i in range (1,15):
print("math.remainder(13,{:2d})".format(i),math.remainder(13,i))
Output
math.remainder(13, 1) 0.0
math.remainder(13, 2) 1.0
math.remainder(13, 3) 1.0
math.remainder(13, 4) 1.0
math.remainder(13, 5) -2.0
math.remainder(13, 6) 1.0
math.remainder(13, 7) -1.0
math.remainder(13, 8) -3.0
math.remainder(13, 9) 4.0
math.remainder(13,10) 3.0
math.remainder(13,11) 2.0
math.remainder(13,12) 1.0
math.remainder(13,13) 0.0
math.remainder(13,14) -1.0
← Subscribe to our YouTube Channel here