python % operator site:stackoverflow.com - Search
About 4,080,000 results
Open links in new tab
    Kizdar net | Kizdar net | Кыздар Нет
  1. What does colon equal (:=) in Python mean? - Stack Overflow

    Mar 21, 2023 · The code in the question is pseudo-code; there, := represents assignment. For future visitors, though, the following might be more relevant: the next version of Python (3.8) will gain a new operator, :=, allowing assignment expressions (details, motivating examples, and discussion can be found in PEP 572, which was provisionally accepted in late June 2018).

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

    Aug 23, 2024 · In Python 2.2 or later in the 2.x line, there is no difference for integers unless you perform a from __future__ import division, which causes Python 2.x to adopt the 3.x behavior. Regardless of the future import, 5.0 // 2 will return 2.0 since …

  3. What does the ** maths operator do in Python? - Stack Overflow

    It is the power operator. From the Python 3 docs: The power operator has the same semantics as the built-in pow() function, when called with two arguments: it yields its left argument raised to the power of its right argument. The numeric arguments are first converted to a common type, and the result is of that type.

  4. What does the “at” (@) symbol do in Python? - Stack Overflow

    Jun 17, 2011 · In Python 3.5 you can overload @ as an operator. It is named as __matmul__, because it is designed to do matrix multiplication, but it can be anything you want. See PEP465 for details. This is a simple implementation of matrix multiplication.

  5. What does the percentage sign mean in Python [duplicate]

    Apr 25, 2017 · It's an operator in Python that can mean several things depending on the context. A lot of what follows was already mentioned (or hinted at) in the other answers but I thought it could be helpful to provide a more extensive summary. % for Numbers: Modulo operation / Remainder / Rest. The percentage sign is an operator in Python. It's described as:

  6. syntax - Python integer incrementing with ++ - Stack Overflow

    @TimPietzcker: a better solution would be to well define the evaluation order, probably from left to right, rather than dropping a useful operator. And to the OP: Python is hardly a modern language... and is a quite crappy language actually, despite being widely used. –

  7. python - What does the caret (^) operator do? - Stack Overflow

    Dec 14, 2021 · As a side note, the __r*__ version of these (like __rxor__ or __radd__) will be invoked from the argument appearing on the right hand side of the infix symbol, and only if the call to the function for the left hand symbol doesn't work.

  8. syntax - What do >> and << mean in Python? - Stack Overflow

    Apr 3, 2014 · Where as print(100>>3) , worked perfect. I did manual calculation and cheked the print result from python. It worked correctly. Dropped last 3 bits and added value '0' to first 3 bits. Looks like (100<<3) , left shift operator has a bug on Python.

  9. Behaviour of increment and decrement operators in Python

    Sep 28, 2009 · Python does not have unary increment/decrement operators (--/++). Instead, to increment a value, use . a += 1 More detail and gotchas. But be careful here. If you're coming from C, even this is different in python. Python doesn't have "variables" in the sense that C does, instead python uses names and objects, and in python ints are immutable.

  10. >> operator in Python - Stack Overflow

    Aug 5, 2010 · Its the right shift operator. 10 in binary is 1010 now >> 1 says to right shift by 1 , effectively loosing the least significant bit to give 101 , which is 5 represented in binary. In effect it divides the number by 2 .