Python Modulo: Using the % Operator
Christopher Trudeau
33:55
Description
Python supports a wide range of arithmetic operators that you can use when working with numbers in your code. One of these operators is the modulo operator (%), which returns the remainder of dividing two numbers. Modular operations are useful to check if a number is even or odd, simplifying cycling through data, and doing non-decimal based units conversion.
In this course, you’ll learn:
The code in this course was tested with Python 3.9.0, % has not change much and older versions should be compatible.
What You'll Learn?
- How modulo works in mathematics
- How to use the Python modulo operator with different numeric types
- How Python calculates the results of a modulo operation
- How to override
.__mod__()
in your classes to use them with the modulo operator - How to use the Python modulo operator to solve real-world problems
More details
User Reviews
Rating
Christopher Trudeau
Instructor's CoursesChristopher has a passion for the Python language and writes for Real Python. He is a consultant who helps advise organizations on how to improve their technical teams. Christopher is a strong advocate for automation throughout the delivery process and the power of small teams with well defined goals.
You can find Christopher here:

Real Python
View courses Real Python- language english
- Training sessions 6
- duration 33:55
- Release Date 2023/01/05