There's the % sign. It's not just for the remainder, it is the modulo operation.
Python
docs.python.org › 3 › library › math.html
math — Mathematical functions
3 weeks ago - This module provides access to common mathematical functions and constants, including those defined by the C standard. These functions cannot be used with complex numbers; use the functions of the ...
Readthedocs
mod.readthedocs.io
mod – modular arithmetic in Python — mod 0.3.0 documentation
from mod import Mod # Funny math here x = Mod(5, 7) # x ≡ 5 (mod 7) (x + 2) == 0 # True: 5 + 2 ≡ 7 ≡ 0 (mod 7) (x + 7) == x # True: 5 + 7 ≡ 12 ≡ 5 (mod 7) (x**3) == (x + 1) # True: 5³ ≡ 125 ≡ 6 (mod 7) (1 // x) == 3 # True: 5 × 3 ≡ 15 ≡ 1 (mod 7) ⇒ 5⁻¹ ≡ 3 (mod 7)
Videos
01:44
Python Modulo: Using the % Operator (Overview) (Video) – Real Python
08:13
Performing Modulo Operation in Python - YouTube
04:25
How To Use Modulo Operations In Python - YouTube
20:14
Mathematics with Python! Modular Arithmetic - YouTube
10:36
Using the Python Modulo % Operator - YouTube
04:53
math basics - modulus (Python) - YouTube
Hyperskill
hyperskill.org › university › python › modulo-operator-in-python
Modulo Operator in Python
July 23, 2024 - This course is dedicated to core ... or Data Science. ... The modulo operator, often denoted as “%”, is a mathematical operation that finds the remainder when one number is divided by another....
Reddit
reddit.com › r/learnpython › modulo operator
r/learnpython on Reddit: Modulo operator
November 22, 2023 -
Hey guys, I just started learning python and im learning about "modulo operator" in the codeacademy free course and my english isn't perfect and im not good at math at all so i'm lost, and also idk if i should be seeing this if literally i dont know anything about coding, just starting the basics. ty
Top answer 1 of 5
19
A modulo is a mathematical operator used in modular arithmetic You can think about modular arithmetic like how time on an analog clock works. In a 12 hr clock, if it’s currently 10, in 3 hours it will be 1, not 13. This is expressed as 10 + 3 mod 12. The modulo operator returns that result. num = (10 + 3) % 12 print(num) Would output 1. People like thinking about this as the remainder, but that’s not really accurate. For example: -1 % 4 would actually equal 3. If you think about a 4-hr clock and go back 1 hour, you end up at 3.
2 of 5
4
When I was at school we called it remainder. What is 11 divided by 3? The answer is 3 remainder 2. The modulo operator gives you the remainder part of the division, ignoring the main answer. So 11 % 3 gives 2 And hence N % M always returns an answer between 0 and (M - 1).
Mimo
mimo.org › glossary › python › modulo-operator
Mimo: The coding platform you need to learn Web Development, Python, and more.
Use the Python modulo operator to get remainders, build cycles, and check parity with examples.
Real Python
realpython.com › python-modulo-operator
Python Modulo Operator (%): How to Use Mod in Python – Real Python
April 1, 2023 - Just like with the division operator (/), Python will return a ZeroDivisionError if you try to use the modulo operator with a divisor of 0: ... Next, you’ll take a look at using the modulo operator with a float. Similar to int, the modulo operator used with a float will return the remainder of division, but as a float value: ... An alternative to using a float with the modulo operator is to use math.fmod() to perform modulo operations on float values:
AskPython
askpython.com › home › python modulo – % operator, math.fmod() examples
Python Modulo - % Operator, math.fmod() Examples - AskPython
February 16, 2023 - Python modulo operator always return the remainder having the same sign as the divisor. This can lead to some confusion with the output. ... The behavior of % operator with negative numbers is different from the platform C library. If you want the modulo operation to behave like C programming, you should use math module fmod() function.
GitHub
github.com › yoeo › mod
GitHub - yoeo/mod: Modular arithmetic in Python :100:
The purpose of this package is to simplify the use of modular arithmetic in Python3. This package provides Mod integers that compute arithmetic operations like + - * // ** with a modulus: from mod import Mod # Funny math here x = Mod(5, 7) # x ≡ 5 (mod 7) (x + 2) == 0 # True: 5 + 2 ≡ 7 ≡ 0 (mod 7) (x + 7) == x # True: 5 + 7 ≡ 12 ≡ 5 (mod 7) (x**3) == (x + 1) # True: 5³ ≡ 125 ≡ 6 (mod 7) (1 // x) == 3 # True: 5 × 3 ≡ 15 ≡ 1 (mod 7) ⇒ 5⁻¹ ≡ 3 (mod 7)
Starred by 13 users
Forked by 4 users
Languages Python 100.0% | Python 100.0%
DataCamp
datacamp.com › tutorial › modulo-operator-python
Modulo Operator in Python: Understanding Key Concepts | DataCamp
March 12, 2025 - The modulo operator (%) in Python calculates the remainder of a division operation. It follows a consistent mathematical formula:
Upgrad
upgrad.com › home › tutorials › software & tech › modulus in python
Modulus in Python | Definition, Syntax & Use Cases
June 2, 2025 - For example, -17 % 5 returns 3. The math.fmod() function provides more precision than the % operator when calculating the modulus for floating-point numbers, especially with very small or large decimal numbers.
Codecademy
codecademy.com › docs › python › modulo
Python | Modulo | Codecademy
April 15, 2025 - The modulo operator (%) in Python calculates the remainder of a division operation between two operands. When one number is divided by another, the modulo operation returns what remains after the division is performed.
Python Central
pythoncentral.io › how-to-use-the-operator-a-set-of-python-modulo-examples
How To Use The % Operator: A Set of Python Modulo Examples | Python Central
April 27, 2023 - It's important to remember that if you use the modulo operator with a divisor 0, Python will throw a ZeroDivisionError. This same error appears if you use the division operator with zero. >>> 55 % 0 ZeroDivisionError: integer division or modulo by zero · Using the modulo operator with a float value also returns the remainder of division, but the resultant value is a float value. Here's an example: ... Besides using the modulo operator directly with float values, you can use the math.fmod() function to apply the modulo operator on any float value.