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

    On Python 3 the calculation yields 6.75; this is because the / does a true division, not integer division like (by default) on Python 2. On Python 2 1 / 4 gives 0, as the result is rounded down.

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

    Oct 7, 2010 · Python Modulo for Dummies Modulo function is a directional function that describes how much we have to move further or behind after the mathematical jumps that we take during division …

  3. python - Find the division remainder of a number - Stack Overflow

    That's because Python's % performs a true modulus, which returns values on the range [0, divisor) and pairs well with floored division (towards negative infinity). C languages use the % operator for …

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

    Jun 13, 2009 · I don't think you're fully grasping modulo. a % b and a mod b are just two different ways to express modulo. In this case, python uses %. No, 15 mod 4 is not 1, 15 % 4 == 15 mod 4 == 3.

  5. python - Division & Modulo Operator - Stack Overflow

    Sep 2, 2016 · python python-2.x division modulo modulus edited Sep 4, 2016 at 4:38 jwodder 58.1k 12 116 134

  6. Division modular en Python - Stack Overflow en español

    Apr 21, 2021 · Estoy haciendo una función donde defino que el tamaño del bloque es de 4096kb y usando la division modular tengo que saber cuál sería el tamaño del bloque que usaría un archivo …

  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 returns the …

  8. The modulus operator (%) in python - Stack Overflow

    May 9, 2019 · It is used to calculate the remainder of an integer division, like 5 % 3 which yields 2. It returns the remainder for all numeric operands on the left-hand-side (that is, if the first operands is an …

  9. Python modulo on floats - Stack Overflow

    Feb 8, 2013 · Modulo gives you the rest of a division. 3.5 divided by 0.1 should give you 35 with a rest of 0. But since floats are based on powers of two the numbers are not exact and you get rounding errors.

  10. math - `/` vs `//` for division in Python - Stack Overflow

    Aug 23, 2024 · In Python 3.x, 5 / 2 will return 2.5 and 5 // 2 will return 2. The former is floating point division, and the latter is floor division, sometimes also called integer division. In Python 2.2 or later …