About 1,290,000 results
Open links in new tab
  1. What is the result of % (modulo operator / percent sign) in Python?

    This is because in JavaScript % is the "remainder" operator while in Python it is the "modulus" (clock math) operator. You can get the explanation directly from GvR: Edit - dahiya_boy In …

  2. Modulo operator in Python - Stack Overflow

    What does modulo in the following piece of code do? from math import * 3.14 % 2 * pi How do we calculate modulo on a floating point number?

  3. Understanding The Modulus Operator - Stack Overflow

    Jul 8, 2013 · 0 Modulus operator gives you the result in 'reduced residue system'. For example for mod 5 there are 5 integers counted: 0,1,2,3,4. In fact 19=12=5=-2=-9 (mod 7). The main …

  4. Python modulo on floats - Stack Overflow

    Feb 8, 2013 · Can anyone explain how the modulo operator works in Python? I cannot understand why 3.5 % 0.1 = 0.1.

  5. How does the modulo (%) operator work on negative numbers in …

    Oct 7, 2010 · Exactly how does the % operator work in Python, particularly when negative numbers are involved? For example, why does -5 % 4 evaluate to 3, rather than, say, -1?

  6. Modular multiplicative inverse function in Python - Stack Overflow

    201 Does some standard Python module contain a function to compute modular multiplicative inverse of a number, i.e. a number y = invmod(x, p) such that x*y == 1 (mod p)? Google …

  7. python - If statement with modulo operator - Stack Overflow

    Nov 8, 2016 · Open up the Python console, and do 4 % 2, what is the result? Then do 3 % 2, what is the result? Now which of the results would be considered "true"? The modulo operator …

  8. python - Modulo Operation for Odd & Even Number - Stack …

    Jan 5, 2022 · If you're trying to use a different modulus such as % 7, you might get funky results, that's not a code issue but rather more of a modulo problem, as it's very common to use % 2.

  9. How to calculate a mod b in Python? - Stack Overflow

    Jun 13, 2009 · Is there a modulo function in the Python math library? Isn't 15 % 4, 3? But 15 mod 4 is 1, right?

  10. C and Python - different behaviour of the modulo (%) operation

    Python has a "true" modulo operation, while C has a remainder operation. It has a direct relation with how the negative integer division is handled, i.e. rounded towards 0 or minus infinite. …