Token (OPERATOR)

Operator: Operator are tokens that does computation(calculation) with designated or given values in expression. Operators when applied on operands form an expression.

Operand: Operand is the value or variable on which calculation is performed.

Operators are can be classified in three categorize:

1. Arithmetic Operator: Arithmetic operators are those operators which are used for arithmetic or mathematical calculations. In Python, the arithmetic operators are:

  1.  Addition (+) : It is used to sum two operands.
  2.  Subtraction (-) : It gives difference between two operands.
  3.  Multiplication ( * ) : It gives us product of the two operands.
  4.  Division (/) : It gives us Quotient of the two operands.
  5. Floor Division ( // ) : It gives us quotient of two operands(without fractional part).
  6. Modules ( % ) : It gives us integer remainder after division of 'a' by 'b' -(a % b).
  7. Exponent ( ** ) : It gives us product of 'a' by itself  'b' times(a to the power of b).

2. Relational Operator : Relational operators are those operators which are used to compare aarithmatical and logical expressions. It is also known as ' Comparison Operator'.

  1. Greater than(>) : Gives result true if the left operand is greater than the right operand.
  2. Less than (<) : Gives result true if the left operand is less than the right.
  3.  Equal to (= =) : Gives result true if both operand are equal.
  4.  Not Equal to (!=) : Gives result true if both operand are not equal.
  5. Greater than/Equal to ( >=) : Gives result true if left operand is greater than or equal to the right operand.
  6. Less than/ Equal to (<=) : Gives result true if the left operand is less than or equal to the right operand.

3. Logical operator : Logical operators are used when there is a situation for evaluating two or more relational expressions. In python, there are three logical operators are commonly used:

    1. Logical AND (and) : this operator is written as 'and'. It combines two expression into one. The resulting expression evaluates to 'True' only if both the conditions satisfies to 'true'.

    


     2. Logical OR (or) : This operator is written as 'or'. It combines two expressions into one. The resulting expression evaluates to 'True' when either of the conditions satisfies to 'True'.

                                            


     3. Logical NOT (not) : This operator is written as 'not'. It works with single expression or operand. it is a unary operator. This operator negates or reverse the truth value of the expression. In other words, if the expression is 'true', then the use of 'not' expression makes it 'False' and vice versa.

                                        



Comments

Post a Comment

Popular posts from this blog

Computer Basic

Character Set and Tokens in Python

DATABASE INTRODUCTION