Monday, 27 May 2019

Operators

What is Operator?

An operator is a symbol which is used to perform an operation on operands (values and variables).
Operators are either represented by keywords or special characters. For example, for identity operators we use the keyword "is" and "is not".

What is Operand?
The operand may be variable or value.

Example
total=154.34 # one variable is initialized with value

Here total is variable, 154.34 is the value of the variable (operand), ‘=’ is an operator.

Ex2: c=a+b, the operator ‘+’ is acting on two operands ‘a’ and ‘b’.

Classification of operators:

1. Unary Operators
2. Binary Operators
3. Ternary Operators

1. Unary Operators 

Unary: If an operator acts on a single variable, it is called unary operator.
a=-b

2. Binary Operators
If an operator acts on two variables then it is a binary operator

3. Ternary Operators 
If an operator acts on three variables /operands, then it is called the ternary operator.


Types of operators:
1.  Arithmetic
2.  Assignment
3.  Relational operators
4.  Logical operator
5.  Boolean operator
6.  Bitwise operator
7.  Membership
8.  Identity operators

Youtube channel Related video
Next topic: Arithmetic Operators
Previous topic: bytearray

No comments:

Post a Comment

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(...