Operators

Types :
  • Arithmetic Operators
  • Assignment Operators
  • Comparison Operators
  • Logical Operators
  • Identity Operators
  • Membership Operators
  • Bitwise Operators

Assignment Operators:

            The assignment operator is used to assign values to a variable. In some cases, we have to assign a variable’s value to another variable, in such cases the value of the right operand is assigned to the left operand. One of the basic signs from which we can recognize an assignment operator is that it must have an equal-to(=) sign. Some commonly used assignment operators include +=, -=, /=, etc.

 

Comparison Operators:

            They are also known as relational operators. They compare the values on either side of the operator and decide the relation among them. Commonly used comparison operators include ==, >, < , >=,etc.

 

Logical Operators:

            Logical operators perform logical AND, OR and NOT, operations. They are usually used in conditional statements to join multiple conditions. AND, OR and NOT keywords are used to perform logical operations.

 

Identity Operations:

   Identity operator checks if two operands share the same identity or not, which means that they share the same location in memory or different. “is” and “is not” are the keywords used for identity operands.

 

Membership Operands:

            Membership operand checks if the value or variable is a part of a sequence or not. The sequence could be string, list, tuple, etc. “in” and “not in” are keywords used for membership operands.

 

Bitwise Operand:

            Bitwise operands are used to perform bit by bit operation on binary numbers. First, we have to change the format of the number from decimal to binary and then compare them using AND, OR, XOR, NOT, etc.  





My Code:

#21 Operators
#Arithmetic Operators
#Assignment Operators
#Comparison Operators
#Logical Operators
#Identity Operators
#Membership Operators
#Bitwise Operators


#Arithmetic Operators
#print(5+6)
#print(5**3)
#print(6/3)
#print(6//3)
#print(6*3)

#Assignment Operators
#x=5
#print(x)
#print(x+12)

#Comparison Operators
#i=8
#print(i==5)

#Logical Operators
#a=True
#b= False
#print(a and a)
#print(a and b)
#print(a or b)

#Identity Operators
#print(5 is 7)
#print(5 is not 7)
#print(5 is 5)
#print(5 is not 5)
#here we use == for is and != for not is

#Membership Operators
# list= [1, 2,55,5555, 77,67,7]
# print(1 in list)
# print(22 in list)

#Bitwise Operators
#Bits are binary numbers that is 1 or 0

Comments

Popular posts from this blog

Pickle Module

Python File IO Basics