1. Home
  2. Docs
  3. Programming with Python
  4. Introduction to Python
  5. Python Operators

Python Operators

Operators in Python are special symbols or keywords used to perform operations on variables and values. Python supports a variety of operators, which can be categorized into different types.

Arithmetic operators are used to perform mathematical operations such as addition, subtraction, multiplication, and division.

image

Comparison operators are used to compare two values and return a Boolean result (True or False).

image 1

Logical operators are used to combine conditional statements.

  • Logical AND ( && )
    • The AND operator is used to combine two or more conditions, and it returns TRUE if both conditions are true and, if either condition is false, the result will be false.
  • Logical OR ( || )
    • The OR operator is used to combine two or more conditions, and it returns TRUE if at least one condition is true.
    • If at least one condition is true, the result is true; if both are false, the result will be false.
  • Logical NOT (!)
    • The NOT operator is used to reverse the boolean value of an expression. If the condition is true, it makes it false, and if it is false, it makes it true.
image 2

Assignment operators are used to assign values to variables.

image 3

Bitwise operators work at the binary level (bit-by-bit operation).

image 4

Membership operators are used to check if a value exists in a sequence.

image 5

Identity operators are used to compare the memory location of two objects.

image 6

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *