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

Answer from eduffy on Stack Overflow
🌐
Readthedocs
mod.readthedocs.io
mod – modular arithmetic in Python — mod 0.3.0 documentation
Modular arithmetic is arithmetic ... including: music, banking, book publishing, cryptography… and of course math. The purpose of this package is to simplify the use of modular arithmetic in Python3....
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
🌐
ResearchGate
researchgate.net › publication › 361307525_18_Math_Module_Functions_in_Python
(PDF) 18. Math Module Functions in Python
June 15, 2022 - The math module has a set of methods and constants. ... Return the arc cosne (measured n radans) of x. The result s between 0 and p. The parameter must be a double value between -1 and 1. ... Return the arc cosine (measured in radians) of x. The result is between 0 and pi. ... Return the inverse hyperbolic cosine of x. ... localhost:8888/notebooks/Desktop/PROGRAMMING/PYTHON_TUTORIAL/01.
🌐
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.
🌐
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 - Now that you understand how the modulo operation works in arithmetic let's see how you can use the operation in Python. The % operator is like any other arithmetic operator in Python, and you can use it with int and float numeric types. You can also use the operator in classes you create and with existing methods like math.fmod().
Find elsewhere
🌐
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:
🌐
Python
docs.python.org › 3 › library › math.html
math — Mathematical functions
1 month ago - Note that modf() has a different call/return pattern than its C equivalents: it takes a single argument and return a pair of values, rather than returning its second return value through an ‘output parameter’ (there is no such thing in Python).
🌐
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.
🌐
DataCamp
datacamp.com › tutorial › modulo-operator-python
Modulo Operator in Python: Understanding Key Concepts | DataCamp
March 12, 2025 - Use math.fmod() when the sign of the dividend must be preserved, such as in physics simulations or mathematical functions. As we've seen in earlier examples, Python's implementation of the modulo operator with negative numbers might not align with initial intuition.
🌐
GeeksforGeeks
geeksforgeeks.org › python › what-is-a-modulo-operator-in-python
Modulo operator (%) in Python - GeeksforGeeks
December 20, 2025 - Here, a is divided by b, and the modulo operator returns the remainder left after the division. Python also supports modulo operations with floating-point and negative numbers.
🌐
Analytics Vidhya
analyticsvidhya.com › home › python modulo operator
Python Modulo Operator
April 28, 2025 - It’s a fundamental concept in programming and mathematics with many applications. Also Read: Python Operators: A Comprehensive Guide · Division: The modulo operation involves two numbers. The first number is divided by the second number.
🌐
Career Karma
careerkarma.com › blog › python › how to use the python modulo operator
How to Use the Python Modulo Operator | Career Karma
December 1, 2023 - The modulo operator allows you to determine if a number is odd or even. Remember from math class that numbers divisible by two are even and any other number is odd.
🌐
University of Oxford
users.physics.ox.ac.uk › ~pierrehumbert › PrinciplesPlanetaryClimate › Python › ComputerHandbook.pdf pdf
Mathematical Methods in Python A companion to Principles of Planetary Climate
place of a pocket calculator, especiallly once you learn how to import the standard math functions · into your Python world. These examples illustrate the use of floating point numbers, multiplication · and addition (”*”, ”+” and ”/) assignment to variables, integers, and exponentiation ”**”. The · final example illustrates the use of the ”mod” operator, % which is a binary operator applied ·
🌐
PrepBytes
prepbytes.com › home › python › python mod function
Python Mod() Function
August 17, 2023 - Explanation: In this implementation, we use the fmod() function from the math module to calculate the remainder of the division operation.
🌐
Medium
amenoren.medium.com › pythons-modulo-5180441434dc
Python’s Modulo Operator - Annika Noren - Medium
3 weeks ago - Additionally, a negative float or integer can be used with the modulo operator or math.fmod(). The result takes the sign of the denominator, not the numerator. Key to keep in mind! ... Python also has a built-in function called the divmod(a,b) that will return the quotient and remainder as ...
🌐
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) # ...
Starred by 13 users
Forked by 4 users
Languages   Python 100.0% | Python 100.0%
🌐
Hyperskill
hyperskill.org › university › python › modulo-operator-in-python
Modulo Operator in Python
July 23, 2024 - When using the modulo operator with floats, rounding and precision can affect the result. To address this, the math.fmod() function can be used, which specifically calculates the remainder of the division between two floating-point numbers, considering rounding and precision issues.
🌐
Codingem
codingem.com › home › modulo (%) in python: a complete guide (10+ examples)
Modulo (%) in Python: A Complete Guide (10+ Examples)
November 8, 2022 - In Python, a common way to calculate modulo is using the dedicated modulo operator %. Alternatively, if you want to know both the result of the division and the remainder, you can use the built-in divmod() function.
🌐
Real Python
realpython.com › videos › modular-arithmetic
Modular Arithmetic (Video) – Real Python
-3 minus -8 gives you 5. Once again, simple division gives you a whole factor of 5, so -3 and -8 are congruent mod 5. 03:29 That’s enough background. Next up, let’s see how this works inside of Python. Become a Member to join the conversation. ... Get a Python Cheat Sheet (PDF) and learn the basics of Python, like working with data types, dictionaries, lists, and Python functions:
Published   May 9, 2020