Course Content

Operators In Python

Today's tutorial is more about theoretical learning than coding because we must have basic knowledge about, what we are actually implementing in our code because if our basis is strong only then we can make an efficient program of a larger scale.

“Operators in Python can be defined as symbols that assist us to perform certain operations. The operations could be between variable and variable, variable and value, value and value”

Operators that Python Language supports are:

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

We must remember most of them from our basic mathematics that we studied in school. May be except for the last one, that might be new for some of us. To understand bitwise fully, we must have the basic knowledge of the conversion of decimal into binary. For example, the binary for the first five number is:

  • 0001
  • 0010
  • 0011
  • 0100
  • 0101

And so on.

Now I will give you a theoretical understanding of each of these operators. There is no theory related difference in them and the one we studied during school. The only difference you will see will be in the syntax i.e. how to write them for perfect execution.

Arithmetic Operators:

            Basic mathematical operations such as addition, multiplication, subtraction, division, etc. are performed with the help of arithmetic Operations. It contains nearly all operations that we can perform with the help of a calculator. Symbols for such operators include *, /, %, -, //, etc.

           

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.

Code file as described in the video

# list1 = [ ["Harry", 1], ["Larry", 2],
#           ["Carry", 6], ["Marie", 250]]
# dict1 = dict(list1)
#
# for item in dict1:
#     print(item)
# for item, lollypop in dict1.items():
#     print(item, "and lolly is ", lollypop)
items = [int, float, "HaERRY", 5,3, 3, 22, 21, 64, 23, 233, 23, 6]

for item in items:
    if str(item).isnumeric() and item>=6:
        print(item)

Comments(16)

ahmedraza 4 months, 3 weeks ago
where is source code
ahmedraza 4 months, 3 weeks ago
give me source code else:
i ma report your website 
ahmedraza 4 months, 3 weeks ago
give me source code else: i am report your website
ahmedraza 4 months, 3 weeks ago
you have just 1 hour give me source code
ahmedraza 4 months, 3 weeks ago
harry over team unsubscribe your channel : because you tell about source code in video but you are not give source code,,,
over team have 123 members :
all of members unsubscribe your channel after 1 days .
so give source code>..
shellstar 1 week, 6 days ago
source code video me dekh ke likho na kyu harry sir ko pareshan karrahe ho
ahmedraza 4 months, 3 weeks ago
harry 
ahmedraza 4 months, 3 weeks ago
narry
ahmedraza 4 months, 3 weeks ago
carry 
ahmedraza 4 months, 3 weeks ago
merry
ahmedraza 4 months, 3 weeks ago
harry carry merry nerry :> give me source code
ahmedraza 4 months, 3 weeks ago
i am don
ahmedraza 4 months, 3 weeks ago
main hon jeyan
Vivek-Mishra 1 month, 3 weeks ago
Thanks, Harry Bhai for Awesome Tutorials |:::::::::::::::::| Full Notes and Source Code :::::::::::::} https://github.com/Optimized-World/Complete-Python-Tutorial-and-Notes
himanshu9 3 weeks, 2 days ago
sir you are best !!! I think I will be a pro programmer because of this all tutorials .
shellstar 1 week, 5 days ago
alert('hii')

Resources

No downloadable resources for this video. If you think you need anything, please post it in the QnA!

Course Announcements

Any Course related announcements will be posted here