Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Calculate Modulus

Learn how to calculate the modulus of two numbers using the modulo operator.

Python practice28 minAdvancedLast updated December 26, 2025

Problem statement

Write a function that takes two integers and returns the modulus of the first integer divided by the second integer. The modulus is the remainder after division.

Task

Understand the concept of modulus and how to implement it in Python.

Examples

Example 1

Input

calculate_modulus(10, 3)

Output

1

10 divided by 3 is 3 with a remainder of 1.

Input format

Two integers a and b (0 < b)

Output format

An integer that represents the modulus of a divided by b.

Constraints

0 < b <= 1000, -1000 <= a <= 1000

Samples

Sample 1

Input

calculate_modulus(10, 3)

Output

1

The modulus of 10 divided by 3 is 1.