Operators in Python

Anuradha GuptaAnuradha Gupta
2 min read

In Python, operators are symbols that perform operations on variables and values. Here's an overview of the different types of operators in Python:

  1. Arithmetic Operators: Used for basic arithmetic operations.

    • Addition (+)

    • Subtraction (-)

    • Multiplication (*)

    • Division (/)

    • Modulus (%)

    • Exponentiation (**)

    • Floor division (//)

  2. Comparison (Relational) Operators: Used to compare 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.

    • Logical AND (and)

    • Logical OR (or)

    • Logical NOT (not)

  4. Assignment Operators: Used to assign values to variables.

    • Assignment (=)

    • Add and assign (+=)

    • Subtract and assign (-=)

    • Multiply and assign (*=)

    • Divide and assign (/=)

    • Modulus and assign (%=)

    • Exponentiate and assign (**=)

    • Floor divide and assign (//=)

  5. Identity Operators: Used to compare the memory locations of two objects.

    • is

    • is not

  6. Membership Operators: Used to check if a value is present in a sequence (like lists, tuples, or strings).

    • in

    • not in

  7. Bitwise Operators: Used to perform bitwise operations on integers.

    • Bitwise AND (&)

    • Bitwise OR (|)

    • Bitwise XOR (^)

    • Bitwise NOT (~)

    • Left shift (<<)

    • Right shift (>>)

These operators are used extensively in Python programming for various tasks like arithmetic calculations, logical operations, comparisons, and more.

Learn more lesson like this:

Break, Pass, and Continue Statements in Python

While loop in Python

0
Subscribe to my newsletter

Read articles from Anuradha Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Anuradha Gupta
Anuradha Gupta