Remainder of division in Python
There is a special operator %
, with which you can find the remainder of dividing one number by another:
print(10 % 3) # 1
If one number is divisible by the second, the remainder will be zero:
print(10 % 2) # 0
The operator %
can, of course, be applied not only to numbers, but also to variables:
num1 = 10
num2 = 3
print(num1 % num2)
Two numbers are given:
num1 = 13
num2 = 3
Find the remainder when dividing the first number by the second.
Two numbers are given:
num1 = 26
num2 = 8
Find the remainder when dividing the first number by the second.
Two numbers are given:
num1 = -5
num2 = 12
Find the remainder when dividing the second number by the first.