Modulo in Python: Difference between revisions

From Computer Science Wiki
(Created page with "right|frame|This is basic programming knowledge <ref>http://www.flaticon.com/</ref> ==Introduction== {lorem} ==Example of modulo in Python== <syntaxhighl...")
 
Line 3: Line 3:
==Introduction==
==Introduction==


{lorem}
The % (modulo) operator yields the remainder from the division of the first argument by the second. The numeric arguments are first converted to a common type. A zero right argument raises the ZeroDivisionError exception. The arguments may be floating point numbers, e.g., 3.14%0.7 equals 0.34 (since 3.14 equals 4*0.7 + 0.34.) The modulo operator always yields a result with the same sign as its second operand (or zero); the absolute value of the result is strictly smaller than the absolute value of the second operand <ref>https://docs.python.org/2/reference/expressions.html</ref>


==Example of modulo in Python==
==Example of modulo in Python==

Revision as of 13:28, 21 March 2016

This is basic programming knowledge [1]

Introduction[edit]

The % (modulo) operator yields the remainder from the division of the first argument by the second. The numeric arguments are first converted to a common type. A zero right argument raises the ZeroDivisionError exception. The arguments may be floating point numbers, e.g., 3.14%0.7 equals 0.34 (since 3.14 equals 4*0.7 + 0.34.) The modulo operator always yields a result with the same sign as its second operand (or zero); the absolute value of the result is strictly smaller than the absolute value of the second operand [2]

Example of modulo in Python[edit]

# not yet!

References[edit]