René's URL Explorer Experiment


Title: Python Modulo: Using the % Operator (Summary) (Video) – Real Python

Open Graph Title: Python Modulo: Using the % Operator (Summary) – Real Python

Description: In the previous lesson, I showed you how to use .__mod__() and the % operator in your own classes. In this lesson, I’ll wrap up and summarize the course. Python’s % operator and divmod() function are used to calculate division and remainders. 14…

Open Graph Description: In the previous lesson, I showed you how to use .__mod__() and the % operator in your own classes. In this lesson, I’ll wrap up and summarize the course. Python’s % operator and divmod() function are used to calculate division and remainders. 14…

Opengraph URL: https://realpython.com/lessons/python-modulo-summary/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
  {
    "@context": "https://schema.org",
    "@type": "VideoObject",
    "name": "Python Modulo: Using the % Operator (Summary)",
    "description": "In the previous lesson, I showed you how to use .__mod__() and the % operator in your own classes. In this lesson, I’ll wrap up and summarize the course. Python’s % operator and divmod() function are used to calculate division and remainders. 14…",
    "thumbnailUrl": ["https://files.realpython.com/media/Python-Modulo-in-Practice-How-to-Use-the--Operator_Watermarked.e2c969c91ddc.jpg"],
    "uploadDate": "2021-02-09T14:00:00+00:00",
    "duration": "PT3M40S",
    
    "potentialAction": {
      "@type": "SeekToAction",
      "target": "https://realpython.com/lessons/python-modulo-summary/#t={seek_to_second_number}",
      "startOffset-input": "required name=seek_to_second_number"
    }
  }
  

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/Python-Modulo-in-Practice-How-to-Use-the--Operator_Watermarked.e2c969c91ddc.jpg
og:imagehttps://files.realpython.com/media/Python-Modulo-in-Practice-How-to-Use-the--Operator_Watermarked.e2c969c91ddc.jpg
twitter:creator@realpython
og:typevideo.episode

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/lessons/python-modulo-summary/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/lessons/python-modulo-summary/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Flessons%2Fpython-modulo-summary%2F
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=python-modulo-operator
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=python-modulo-operator
https://realpython.com/courses/python-modulo-operator/#team
Python Modulo: Using the % Operatorhttps://realpython.com/courses/python-modulo-operator/
Christopher Trudeauhttps://realpython.com/courses/python-modulo-operator/#team
Recommended Tutorialhttps://realpython.com/python-modulo-operator/
Course Slides (.pdf)https://realpython.com/courses/python-modulo-operator/downloads/modulo-slides/
Sample Code (.zip)https://realpython.com/courses/python-modulo-operator/downloads/modulo-sample-code/
Ask a Questionhttps://realpython.com/lessons/python-modulo-summary/#discussion
https://realpython.com/feedback/survey/course/python-modulo-operator/liked/?from=lesson-title
https://realpython.com/feedback/survey/course/python-modulo-operator/disliked/?from=lesson-title
Contentshttps://realpython.com/lessons/python-modulo-summary/#description
Transcripthttps://realpython.com/lessons/python-modulo-summary/#transcript
Discussionhttps://realpython.com/lessons/python-modulo-summary/#discussion
Python Expressionshttps://docs.python.org/3/reference/expressions.html#index-68
Python Floating Pointhttps://docs.python.org/3/tutorial/floatingpoint.html
IEEE Standard for Floating-Point Arithmetic (IEEE 754)https://en.wikipedia.org/wiki/IEEE_754
Exploring HTTPS and Cryptography in Pythonhttps://realpython.com/courses/exploring-https-cryptography/
Decimal Modulehttps://docs.python.org/3/library/decimal.html
Standard operators as functionshttps://docs.python.org/3/library/operator.html
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson_preview&utm_content=python-modulo-operator
Sign-Inhttps://realpython.com/account/login/
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson_preview&utm_content=python-modulo-operator
Sign-Inhttps://realpython.com/account/login/
00:00https://realpython.com/lessons/python-modulo-summary/#t=0.48
In the previous lesson,https://realpython.com/lessons/python-modulo-summary/#t=0.48
I showed you how to use .__mod__() and the % operator in your own classes.https://realpython.com/lessons/python-modulo-summary/#t=1.56
In this lesson, I’ll wrap up and summarize the course.https://realpython.com/lessons/python-modulo-summary/#t=6.6
00:11https://realpython.com/lessons/python-modulo-summary/#t=11.64
Python’s % operator and divmod() function are used to calculate division andhttps://realpython.com/lessons/python-modulo-summary/#t=11.64
remainders. 14 divided by 4 is 3 remainder 2. Using divmod(),https://realpython.com/lessons/python-modulo-summary/#t=16.14
you can do exactly that calculation, getting the 3 remainder 2.https://realpython.com/lessons/python-modulo-summary/#t=22.77
00:26https://realpython.com/lessons/python-modulo-summary/#t=26.97
Or using the % operator, you can get just the remainder.https://realpython.com/lessons/python-modulo-summary/#t=26.97
The mod operation can be done on both int and float.https://realpython.com/lessons/python-modulo-summary/#t=32.1
The precision problems that you can encounter with float numbers are alsohttps://realpython.com/lessons/python-modulo-summary/#t=36.09
present when you do mod on floats.https://realpython.com/lessons/python-modulo-summary/#t=39.66
00:44https://realpython.com/lessons/python-modulo-summary/#t=44.22
Additionally,https://realpython.com/lessons/python-modulo-summary/#t=44.22
the math module has the fmod() function that also does the modulus operation.https://realpython.com/lessons/python-modulo-summary/#t=44.97
An important thing to note is that the % operator and fmod() calculatehttps://realpython.com/lessons/python-modulo-summary/#t=50.91
negative mods differently. 8 % -3 is -1,https://realpython.com/lessons/python-modulo-summary/#t=56.43
whereas fmod() returns 2.https://realpython.com/lessons/python-modulo-summary/#t=62.13
01:06https://realpython.com/lessons/python-modulo-summary/#t=66.12
In a compound statement,https://realpython.com/lessons/python-modulo-summary/#t=66.12
the % operator has the same precedence as multiplication and division,https://realpython.com/lessons/python-modulo-summary/#t=67.35
so it may be important to use brackets to get the result you’re intending.https://realpython.com/lessons/python-modulo-summary/#t=72.39
01:17https://realpython.com/lessons/python-modulo-summary/#t=77.76
One of the most common uses of the mod operator in coding is to determinehttps://realpython.com/lessons/python-modulo-summary/#t=77.76
whether or not a number is even.https://realpython.com/lessons/python-modulo-summary/#t=81.75
You could do that by doing % 2 and checking for 0. Mod is also veryhttps://realpython.com/lessons/python-modulo-summary/#t=84.21
helpful when you need to cycle through a list,https://realpython.com/lessons/python-modulo-summary/#t=90.21
wanting to loop it back to the beginninghttps://realpython.com/lessons/python-modulo-summary/#t=92.7
without having to check whether or not you’ve passed the end.https://realpython.com/lessons/python-modulo-summary/#t=94.62
01:37https://realpython.com/lessons/python-modulo-summary/#t=97.65
The appropriate use of the mod operator can make your code more succinct andhttps://realpython.com/lessons/python-modulo-summary/#t=97.65
require fewer boundary checks.https://realpython.com/lessons/python-modulo-summary/#t=101.76
Mod is often used for unit conversion as well.https://realpython.com/lessons/python-modulo-summary/#t=105.45
01:48https://realpython.com/lessons/python-modulo-summary/#t=108.75
This tends to be a good place to use divmod(). Converting a total number ofhttps://realpython.com/lessons/python-modulo-summary/#t=108.75
minutes into the number of days, hours, and minutes that ishttps://realpython.com/lessons/python-modulo-summary/#t=113.55
can be done with two quick calls to divmod().https://realpython.com/lessons/python-modulo-summary/#t=117.36
02:00https://realpython.com/lessons/python-modulo-summary/#t=120.81
days and extra_minutes are the divisor and the remainder of the 1440 minutes inhttps://realpython.com/lessons/python-modulo-summary/#t=120.81
a day,https://realpython.com/lessons/python-modulo-summary/#t=127.14
and then taking the result from the previous line and running divmod() on thathttps://realpython.com/lessons/python-modulo-summary/#t=128.31
for 60 will give you the remaining hours and minutes in the calculation.https://realpython.com/lessons/python-modulo-summary/#t=133.17
02:19https://realpython.com/lessons/python-modulo-summary/#t=139.11
Like all operators in Python, % maps to a class method.https://realpython.com/lessons/python-modulo-summary/#t=139.11
The % method maps to .__mod__().https://realpython.com/lessons/python-modulo-summary/#t=144.33
This can be found in Python’s actual source code and is something that you can dohttps://realpython.com/lessons/python-modulo-summary/#t=147.93
yourself when you’re writing your own classeshttps://realpython.com/lessons/python-modulo-summary/#t=151.98
if you wish to support the mod operator.https://realpython.com/lessons/python-modulo-summary/#t=154.2
02:38https://realpython.com/lessons/python-modulo-summary/#t=158.37
One of the best places to get answers to your questions about Python is thehttps://realpython.com/lessons/python-modulo-summary/#t=158.37
Python documentation. Here’s the link to the expressions page.https://realpython.com/lessons/python-modulo-summary/#t=161.82
The subsection on binary arithmetic operations includes information on the modhttps://realpython.com/lessons/python-modulo-summary/#t=166.35
operator. To better understand floating-point,https://realpython.com/lessons/python-modulo-summary/#t=171.9
you can look at the Python floating-pointhttps://realpython.com/lessons/python-modulo-summary/#t=175.5
documentation, or Wikipedia has an article on the IEEE 754 standardhttps://realpython.com/lessons/python-modulo-summary/#t=177.42
that specifies how floating-point arithmetic is meant to work.https://realpython.com/lessons/python-modulo-summary/#t=184.3
03:09https://realpython.com/lessons/python-modulo-summary/#t=189.97
If cryptography is your thing,https://realpython.com/lessons/python-modulo-summary/#t=189.97
the course on exploring HTTPS and cryptography shows you how to use mod tohttps://realpython.com/lessons/python-modulo-summary/#t=191.65
create Caesar ciphers as well as the generation of RSA keys.https://realpython.com/lessons/python-modulo-summary/#t=197.2
03:23https://realpython.com/lessons/python-modulo-summary/#t=203.08
Here’s the link to the Python decimal module,https://realpython.com/lessons/python-modulo-summary/#t=203.08
if you wish to dig into that a little further.https://realpython.com/lessons/python-modulo-summary/#t=205.51
And this page describes all of the dunder methods and what operators map tohttps://realpython.com/lessons/python-modulo-summary/#t=208.42
them. I hope this course has been useful for you.https://realpython.com/lessons/python-modulo-summary/#t=213.55
03:38https://realpython.com/lessons/python-modulo-summary/#t=218.17
Thanks for your attention.https://realpython.com/lessons/python-modulo-summary/#t=218.17
Become a Memberhttps://realpython.com/account/join/
https://realpython.com/lessons/overriding-dunder-mod/
Overviewhttps://realpython.com/courses/python-modulo-operator/
Python Modulo: Using the % Operator (Overview) 01:44 https://realpython.com/videos/python-modulo-overview/
Modular Arithmetic 03:36 https://realpython.com/videos/modular-arithmetic/
Python % Operator 07:00 https://realpython.com/lessons/python-mod-operator/
Common Uses of % 08:57 https://realpython.com/lessons/common-uses-mod/
Advanced Uses and Overriding .__mod__ 09:00 https://realpython.com/lessons/overriding-dunder-mod/
Python Modulo: Using the % Operator (Summary) 03:40 https://realpython.com/lessons/python-modulo-summary/
Privacy Policyhttps://realpython.com/privacy-policy/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.