Operators and Expression in Python

Operators :-

Python consists a set of operators which are used to specify operations to be performed in an expression.

  • Unary Operators :- Operators that used only one operand. ‘+’ and ‘-‘ sign can be used as a sign of addition and subtraction and also as unary operators.
  • Binary Operators :- Operators which use two operands are known as binary operators like multiplication (*), addition (+) etc. are example of binary operators.
  • Membership Operators :- The membership operators (in and in not) are used to test for membership of a sequence, such as string , lists or tuples.
  • Identity Operators :- Identity operator ( is and is not) is used to compare the memory location of two objects by using id (object) functions.

Expression :-

  • Arithmetic Expression :- It is a combination of operands and arithmetic operators such as +,-,*,/ etc.
  • Relational/Conditional Expression :- The Expression that compares two operands using relational operators like >,<,>=,<=, etc. is called relational/conditional expression.
  • Logical Expression :- The logical expression uses logical operators like and, or and not. The logical expression produces boolean result such as True or False.

Categories: News

Tagged as: ,