Movatterモバイル変換


[0]ホーム

URL:


Python Modulo in Practice: How to Use the % Operator

Python Modulo: Using the % Operator

Python supports a wide range ofarithmetic operators that you can use when working withnumbers in your code. One of these operators is themodulo 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:

  • Howmodulo works in mathematics
  • How to use the Python modulo operator with differentnumeric types
  • How Python calculates the results of amodulo operation
  • How to override.__mod__() in your classes to use them with the modulo operator
  • How to use the Python modulo operator to solvereal-world problems

The code in this course was tested with Python 3.9.0,% has not change much and older versions should be compatible.

What’s Included:

Downloadable Resources:

Start Now

Python Modulo: Using the % Operator

6 Lessons 33m

  1. 1. Python Modulo: Using the % Operator (Overview)01:44
  2. 2. Modular Arithmetic03:36
  3. 3. Python % Operator07:00
  4. 4. Common Uses of %08:57
  5. 5. Advanced Uses and Overriding .__mod__09:00
  6. 6. Python Modulo: Using the % Operator (Summary)03:40
Start Now

AboutChristopher Trudeau

Christopher has a passion for the Python language and writes, records, and podcasts for Real Python. He is a consultant who helps advise organizations on how to improve their technical teams.

» More about Christopher

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

← Browse All Courses


[8]ページ先頭

©2009-2026 Movatter.jp