Dremendo Tag Line

Find remainder without modulus operator in Python

input() - Question 19

In this question, we will see how to input 2 integer numbers in Python programming using the input() function and find out the remainder without using modulus operator (%). To know more about input() function click on the input() function lesson.

Q19) Write a program in Python to input 2 integer numbers and find out the remainder without using modulus operator (%).

Program

print('Enter 2 integer numbers')
a=int(input())
b=int(input())
q=a//b
r=a-(b*q)
print('Remainder={}'.format(r))

Output

Enter 2 integer numbers
5
2
Remainder=1                
video-poster