Python site:stackoverflow.com - Search
About 839,000 results
Open links in new tab
    Kizdar net | Kizdar net | Кыздар Нет
  1. What does the ** maths operator do in Python? - Stack Overflow

    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. It is equivalent to 2 16 = 65536, or pow(2, 16)

  2. What is Python's equivalent of && (logical-and) in an if-statement?

    Mar 21, 2010 · There is no bitwise negation in Python (just the bitwise inverse operator ~ - but that is not equivalent to not). See also 6.6. Unary arithmetic and bitwise/binary operations and 6.7. Binary arithmetic operations. The logical operators (like in many other languages) have the advantage that these are short-circuited.

  3. Exponentials in python: x**y vs math.pow(x, y) - Stack Overflow

    Jan 7, 2014 · Difference between Python built-in pow and math pow for large integers. 1. Java Math.exp() and Python math ...

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

    Jun 17, 2011 · Functions, in Python, are first class objects - which means you can pass a function as an argument to another function, and return functions. Decorators do both of these things. If we stack decorators, the function, as defined, gets passed first to the decorator immediately above it, then the next, and so on.

  5. Is there a "not equal" operator in Python? - Stack Overflow

    Jun 16, 2012 · Python is dynamically, but strongly typed, and other statically typed languages would complain about comparing different types. There's also the else clause: # This will always print either "hi" or "no hi" unless something unforeseen happens. if hi == "hi": # The variable hi is being compared to the string "hi", strings are immutable in Python ...

  6. What does colon equal (:=) in Python mean? - Stack Overflow

    Mar 21, 2023 · In Python this is simply =. To translate this pseudocode into Python you would need to know the data structures being referenced, and a bit more of the algorithm implementation. Some notes about psuedocode::= is the assignment operator or = in Python = is the equality operator or == in Python ; There are certain styles, and your mileage may vary:

  7. python - What exactly does += do? - Stack Overflow

    Jan 30, 2011 · In Python, += is sugar coating for the __iadd__ special method, or __add__ or __radd__ if __iadd__ isn't present. The __iadd__ method of a class can do anything it wants. The list object implements it and uses it to iterate over an iterable object appending each element to itself in the same way that the list's extend method does.

  8. slice - How slicing in Python works - Stack Overflow

    In Python 2.7. Slicing in Python [a:b:c] len = length of string, tuple or list c -- default is +1. The sign of c indicates forward or backward, absolute value of c indicates steps. Default is forward with step size 1. Positive means forward, negative means backward. a -- When c is positive or blank, default is 0. When c is negative, default is -1.

  9. What does asterisk * mean in Python? - Stack Overflow

    See Function Definitions in the Language Reference.. If the form *identifier is present, it is initialized to a tuple receiving any excess positional parameters, defaulting to the empty tuple.

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

    Dec 14, 2021 · Side note, seeing as Python defines this as an xor operation and the method name has "xor" in it, I would consider it a poor design choice to make that method do something not related to xor like exponentiation. I think it's a good illustrative example of how it simply calls the __xor__ method, but to do that for real would be bad practice. –