Python Modular Division Operator

Modular Division Operator

Python Modular Division Operator takes two operands, one on the left and other on the right, and returns the remainder when the left operand is divided by the right operand.

The symbol used for Python Modular Division operator is %.

Syntax

Following is the syntax of Modular Division Operator in Python.

result = operand_1 % operand_2

where operand_1 and operand_2 are numbers and the result is the remainder when operand_1 is divided by operand_2.

Example 1: Modular Division of Integers

In this example, we shall take two integers, divide one with another, find the remainder of this division operation, and print the result.

Python Program

a = 13
b = 5

result = a % b
print('Remainder :', result)
Run Code Copy

Output

Remainder : 3

Example 2: Modular Division of Floating Point Numbers

We can compute the remainder of division of floating point numbers. In the following example, we initialize two floating-point numbers, and find result of Modular Division done using these floating-point numbers.

Python Program

a = 13.8
b = 5.1

result = a % b
print('Remainder :', result)
Run Code Copy

Output

Remainder : 3.6000000000000014

Summary

In this tutorial of Python Examples, we learned what Python Multiplication Arithmetic Operator is, how to use it to find the product of two or more numbers.

Related Tutorials

Code copied to clipboard successfully 👍