Skip to Content

Python Basics: Which Python Operator Is Used to Find the Remainder of Division?

How Does the Modulo Operator (%) Work in Python Calculations?

Learn about the modulo operator (%) in Python, which calculates the remainder of a division. Understand how this operator differs from standard division (/) and floor division (//) and see examples of its use in programming.

Question

Which operator returns the remainder of a division?

A. //
B. **
C. /
D. %

Answer

D. %

Explanation

% computes the remainder (modulo) of division.

When you use the % operator, it divides the left operand by the right operand and yields the leftover value. For example, 10 % 3 evaluates to 1 because 10 divided by 3 is 3 with a remainder of 1. This operator is very useful in programming for tasks like determining if a number is even or odd (e.g., number % 2 == 0) or for cycling through a fixed number of states.

The other options represent different arithmetic operations:

  • The // operator performs floor division. It divides the numbers and rounds the result down to the nearest whole number. For example, 10 // 3 evaluates to 3.
  • The ** operator is the exponentiation operator. It raises the left operand to the power of the right operand. For example, 10 ** 3 evaluates to 1000.
  • The / operator performs true division or float division. It always returns a floating-point number representing the precise result of the division. For example, 10 / 3 evaluates to 3.333….

Python Basics: Learn, Apply & Build Programs certification exam assessment practice question and answer (Q&A) dump including multiple choice questions (MCQ) and objective type questions, with detail explanation and reference available free, helpful to pass the Python Basics: Learn, Apply & Build Programs exam and earn Python Basics: Learn, Apply & Build Programs certificate.