# floor division operator, //, divides two numbers and rounds down to an integer 135 // 60 >> 2 # modulus operator, %, divides two numbers and returns remainder 135 % 60 >> 15 # Applications of modulus operator: # if (x % y ) is zero, then x is divisible by y # extract right-most digit(s) from number: e.g., x % 10 extracts right-most digit of x (in base 10); similarly x % 100 yields last two digits # 1e-15 is Python notation for 10**(-15)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter