Lecture-04 (Python Operators)

 Python  Lecture-01 (Introduction)


1) Arithmetic Operators

2) Assignment operators

3) Bitwise operators

4) Logical Operators

5) Comparison (Relational) Operators

6) Membership Operators

7) Identity Operators

8) Special Operators



Here’s a complete list of Python operators grouped by category:

1) Arithmetic Operators

These are used for performing mathematical operations.

  • + : Addition
  • - : Subtraction
  • * : Multiplication
  • / : Division
  • % : Modulus (remainder)
  • ** : Exponentiation (power)
  • // : Floor division

2) Comparison (Relational) Operators

Used to compare two values.

  • == : Equal to
  • != : Not equal to
  • > : Greater than
  • < : Less than
  • >= : Greater than or equal to
  • <= : Less than or equal to

3)Logical Operators

Used to combine conditional statements.

  • and : Logical AND
  • or : Logical OR
  • not : Logical NOT

4) Bitwise Operators

Operate at the bit level.

  • & : Bitwise AND
  • | : Bitwise OR
  • ^ : Bitwise XOR
  • ~ : Bitwise NOT
  • << : Left shift
  • >> : Right shift

5) Assignment Operators

Used to assign values to variables with additional functionality.

  • = : Assign
  • += : Add and assign
  • -= : Subtract and assign
  • *= : Multiply and assign
  • /= : Divide and assign
  • %= : Modulus and assign
  • **= : Exponentiation and assign
  • //= : Floor division and assign
  • &= : Bitwise AND and assign
  • |= : Bitwise OR and assign
  • ^= : Bitwise XOR and assign
  • >>= : Right shift and assign
  • <<= : Left shift and assign

6) Membership Operators

Check for membership in sequences like strings, lists, or tuples.

  • in : Evaluates to True if a value is found in the sequence.
  • not in : Evaluates to True if a value is not found in the sequence.

7) Identity Operators

Check if two objects are the same in memory.

  • is : Evaluates to True if two variables point to the same object.
  • is not : Evaluates to True if two variables do not point to the same object.

8) Special Operators

  • Ternary Operator: Conditional expression:

    a if condition else b

Operator Precedence

Operators have a specific order of evaluation, which determines how expressions are computed. Would you like details on that too?

Comments