There's the % sign. It's not just for the remainder, it is the modulo operation.

Answer from eduffy on Stack Overflow
🌐
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 ...
Discussions

Modulo operator
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. More on reddit.com
🌐 r/learnpython
48
24
November 22, 2023
Python, unlike C, has the mod operator always return a positive number
There are technically 5 different versions of this operation, though only 2 (possibly 3) are in common use. Common Lisp seems to implement all of them except, somewhat oddly, the euclidean version (the "actual modulo"), its mod function is instead a flooring division · edit: it looks like ... More on news.ycombinator.com
🌐 news.ycombinator.com
169
209
January 3, 2022
People also ask

What is the numpy.mod() function in Python?
The numpy.mod() function calculates the modulus of each element in two arrays element-wise, which is useful when working with large datasets.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › modulus in python
Modulus in Python | Definition, Syntax & Use Cases
What is the purpose of math.fmod() in Python?
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.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › modulus in python
Modulus in Python | Definition, Syntax & Use Cases
Can I calculate modulus for multiple numbers in Python?
Yes, you can calculate the modulus of multiple numbers using a function. For example, a custom function can return the modulus of several numbers sequentially.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › modulus in python
Modulus in Python | Definition, Syntax & Use Cases
🌐
GeeksforGeeks
geeksforgeeks.org › python › what-is-a-modulo-operator-in-python
Modulo operator (%) in Python - GeeksforGeeks
December 20, 2025 - The modulo operator (%) in Python is used to find the remainder after dividing one number by another. It works with both integers and floating-point numbers and is commonly used in tasks like checking even or odd numbers, repeating patterns, ...
🌐
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:
Find elsewhere
🌐
W3Schools
w3schools.com › python › module_math.asp
Python math Module
Python has a built-in module that you can use for mathematical tasks.
🌐
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)
🌐
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.
🌐
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.
🌐
Wikipedia
en.wikipedia.org › wiki › Modulo
Modulo - Wikipedia
2 weeks ago - The range of values for an integer modulo operation of n is 0 to n − 1. a mod 1 is always 0. When exactly one of a or n is negative, the basic definition breaks down, and programming languages differ in how these values are defined. In mathematics, the result of the modulo operation is an ...
🌐
Stanford CS
cs.stanford.edu › people › nick › py › python-math.html
Python Math
Language aside: other languages ... float division and // for int division, and this seems easier to understand. The "modulo" or "mod" operator % is essentially the remainder after int-division....
🌐
Python
docs.python.org › 3 › library › operator.html
operator — Standard operators as functions
The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expression x+y. Many function names are those used for special methods, without the double underscores. For backward compatibility, many of these have a variant with the double underscores kept. The variants without the double underscores are preferred for clarity. The functions fall into categories that perform object comparisons, logical operations, mathematical operations and sequence operations.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.mod.html
numpy.mod — NumPy v2.1 Manual
Equivalent of Python // operator. ... Simultaneous floor division and remainder. ... Equivalent of the MATLAB rem function. ... Returns 0 when x2 is 0 and both x1 and x2 are (arrays of) integers. mod is an alias of remainder.
🌐
PrepBytes
prepbytes.com › home › python › python mod function
Python Mod() Function
August 17, 2023 - The mod function in Python is used to calculate the remainder of a division operation between two numbers. The remainder is the amount left over after the division is performed. For example, the remainder of the division operation 10/3 is 1, ...
🌐
Medium
amenoren.medium.com › pythons-modulo-5180441434dc
Python’s Modulo Operator - Annika Noren - Medium
November 16, 2020 - The basic application of the modulo is to represent the remainder after the division of one number — the numerator — by another number — the denominator. 5 % 2 is 1Two goes into five two times with a remainder of 1. Just like regular math, ...
🌐
Hacker News
news.ycombinator.com › item
Python, unlike C, has the mod operator always return a positive number | Hacker News
January 3, 2022 - There are technically 5 different versions of this operation, though only 2 (possibly 3) are in common use. Common Lisp seems to implement all of them except, somewhat oddly, the euclidean version (the "actual modulo"), its mod function is instead a flooring division · edit: it looks like ...
🌐
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.
🌐
Analytics Vidhya
analyticsvidhya.com › home › python modulo operator
Python Modulo Operator
April 28, 2025 - The Python Modulo, represented by the symbol %, is a mathematical operator that calculates the remainder of a division operation.