x

Python Operators

PREV     NEXT

  • Operators are very familiar with basic mathematics.
  • Operator is nothing but performing the specific operation between operands. It is called the operator.

Operator classification:

  • Operators can be classified based on the operations that they perform or based on the number of operands it operates on.
  • Based on the number of operands, we can classify operators as given below.
  1. Unary Operator
  2. Binary Operator
  3. Ternary Operator

1. Unary Operators

The unary operators operate on a single operand. The addition, subtraction and multiplication operators are used as unary operator in python. We will discuss more about this operator below.


2. Binary Operators

A binary operator is an operator that operates on two operands.

  1. Arithmetic Operators
  2. Assignment Operators
  3. Relational Operators
  4. Logical Operators
  5. Membership operators
  6. Identity operators
  7. Bitwise operators

3. Ternary Operators

The ternary operator is an operator that operates on three operands. The first argument is an expression, If expression is true then second argument will execute else third argument will execute.

Conditional Operators:

Now, we are going in detail of all operators one by one.

1. Arithmetic Operators:

Operator / Meaning    example
 +   (To perform Addition) 23+33=56
 –    (To perform subtraction) 33-23=10
 *    (To perform Multiplication) 10*20=200
 /     (To perform Division (To get the co-efficient)) 20/10=2
 %     (Modulus (To get the reminder)) 5%4=1
 **     (exponent operator(power of)) 2**3=8