Python Program to find remainder without using the modulus operator


In this program, You will learn how to find the remainder without using the modulus operator in Python.


0 = int(10 % 2)

2 = int(2 % 10)

Example: How to find the remainder without using a modulus operator in Python.

x = int(input("Enter first number:"))
y = int(input("Enter second number:"))

while x >= y:
    x = x - y

print("Remainder is:", x)

Output:

Enter first number:12
Enter second number:5
Remainder is: 2