Google News
logo
Python Program to Modulus Operator
The modulus operator in Python is represented by the symbol `%`. It returns the remainder of the division operation.

Here's an example program that demonstrates the use of the modulus operator :
Program :
# take two numbers as input
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))

# calculate the remainder
remainder = num1 % num2

# print the result
print("The remainder of {} divided by {} is {}".format(num1, num2, remainder))
Output :
Enter the first number: 25
Enter the second number: 10
The remainder of 25 divided by 10 is 5
In the above program, the user is asked to enter two numbers. Then, the remainder of the division operation between the two numbers is calculated using the modulus operator. Finally, the result is printed to the console using string formatting.