About 64,400 results
Open links in new tab
  1. python - How does the logical `and` operator work with integers ...

    From the Python documentation: The expression x and y first evaluates x; if x is false, its value is returned; otherwise, y is evaluated and the resulting value is returned. Which is exactly what your experiment shows happening. All of your x values are true, so the y value is returned. https://docs.python.org/3/reference/expressions.html#and.

  2. Python Operators - W3Schools

    Python Identity Operators. Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location:

  3. operator — Standard operators as functions - Python

    2 days ago · Return a converted to an integer. Equivalent to a.__index__(). Changed in version 3.10: The result always has exact type int. Previously, the result could have been an instance of a subclass of int. Return the bitwise inverse of the number obj. This is equivalent to ~obj. Return a shifted left by b. Return a % b. Return a * b, for a and b numbers.

  4. Python Operators Cheat Sheet - LearnPython.com

    May 27, 2024 · Here is the complete list of arithmetic operators in Python: Most of these operators are self-explanatory, but a few are somewhat tricky. The floor division operator ( // ), for example, returns the integer portion of the division between two numbers.

  5. Python Operators - GeeksforGeeks

    Mar 7, 2025 · Python Arithmetic operators are used to perform basic mathematical operations like addition, subtraction, multiplication and division. In Python 3.x the result of division is a floating-point while in Python 2.x division of 2 integers was an integer. To obtain an integer result in Python 3.x floored (// integer) is used.

  6. Arithmetic operators in Python (+, -, *, /, //, %, **) - nkmk note

    Aug 16, 2023 · For numbers, such as integers (int) and floating point numbers (float), you can perform basic arithmetic operations like addition, subtraction, multiplication, division, and exponentiation. For lists or strings, you can perform operations …

  7. Python Arithmetic Operators - W3Schools

    Arithmetic operators are used with numeric values to perform common mathematical operations: Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.

  8. Python Operators - Python Guides

    In Python 2, the / operator performs integer division when both operands are integers. In Python 3, it always performs float division. # Python 3 print(5 / 2) # 2.5 print(5 // 2) # 2 (floor division) Mutable Default Arguments. This isn’t strictly an operator issue, but relates to …

  9. Python Arithmetic Operators - Python Tutorial

    1 Code language: Python (python) You can use the modulus operator to check if a number is odd / even: a = 101 if a % 2 == 1: print(f' {a} is odd.'); else: print(f' {a} is even.'); Code language: Python (python) Try it. Output: 101 is odd. Code language: Python (python) You can also use the % operator to check whether a year is a leap year or not:

  10. 2.3. Operators and Operands — Foundations of Python

    Operators are special tokens that represent computations like addition, multiplication and division. The values the operator works on are called operands. The following are all legal Python expressions whose meaning is more or less clear: The tokens +, -, and *, and the use of parentheses for grouping, mean in Python what they mean in mathematics.

  11. Some results have been removed
Refresh