Operators are used to perform operations on variables and values.
It is used to perform arithmatic operation like Addition,Subtraction,mutiplication,division and modulus.
Types of arithmatic operators is given below:
The word Assignment is stand for 'assign'+'ment' means "assign value to some variable".the value of right side which have same datatype to left side.
Types of assignment operators is given below:
In relational operators, operators compare the values of two operands. For example, if we have two numbers, x
equals 12
and y
equals 13
, we can use operators like >
, <
, <=
, >=
, and ==
. If we compare x < y
, it returns 1
; if x > y
, it returns 0
. Types of relational operators are given below:
When we combine two or more Condition and implement original condition then we are use logical operater
Types of Logical operators is given below
In Python programming there are 6 bitwise operators and
types of Bitwise operators and its function are
The bitwise AND operator is denoted by single ampersand: &. While performing the bitwise AND operation is 1 if both the bits have the value as 1 otherwise, the result is always 0.
a=7 b=11 print("a & b ",a&b)
11
The bitwise OR operator is denoted by: |. While performing the bitwise OR operation is 1 if any one of the bits have the value as 1; otherwise, the result is always 0.
a=7 b=11 print("a|b",a|b)
15
The bitwise NOT operator is denoted by: '~'. While performing the bitwise NOT operation is 1 if bit is 0; otherwise, the result is always 0.
a=7 print("a=",~a)
~7=248
The bitwise Right Shift operator is denoted by: '>';, and when two numbers, right shifts the bits of the first operand, the second operand decides the number of places to shift.
a=7 print(a,">>1=",a>>1)
7>>1=5
The bitwise Left shift operator is denoted by: <, and when two numbers, left shifts the bits of the first operand, the second operand decides the number of places to shift.
a=7 print(a,"<<1=",a<<1)
7<<1=22
Membership operators are used to check the a sequence is present in an object or not.