Facebook Twitter Instagram
    Return ScriptReturn Script
    • Home
    • Jobs
    • OOPs concept
    • Blog
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About Us
    • Contact us
    Return ScriptReturn Script
    pythonbasic

    Types of Operators in Python

    Return ScriptBy Return ScriptSeptember 6, 2021Updated:September 6, 2021No Comments3 Mins Read
    types of operators in python
    types of operators in python

    Python operators are used to performing the operation between values and variables. Additionally, there are different types of operators use in a programming language. In this article, we will discuss these operators in detail by dividing them into different categories. Finally, in this article, you will learn about python operators from basic to advance.

    Arithmetic Operator

    The arithmetic operators use to calculate the mathematical operation between two operands. Additionally, these operations are addition, subtractions, multiplications and divisions. The following table depicts the syntax and description of these operators.

    Arithmetic Operator syntax and description
    Arithmetic Operator

    And following code the actual implementation in a Python programming language.

    X=3
    Y=2
    print(X+Y)
    print(X-Y)
    print(X*Y)
    print(X/Y)
    print(X%Y)
    print(X**Y)
    Output:
    5
    1
    6
    1.5
    1
    9

    Comparison operations

    Comparison operations are the most useful operators it’s generally used for comparing two operands. Moreover, the most common comparison operators are greater than, less than, equals etc. The following table shows the syntax and description of these operands.

    Comparison Operations operators syntax and description
    Comparison operations

    The output of the comparison operation obtains in the form of either True or False. The following code shows how to comparison operations use in a python programming language.

    X=3
    Y=2
    print(X>Y)
    print(X<Y)
    print(X==Y)
    print(X!=Y)
    print(X>=Y)
    print(X<=Y)
    Output:
    True
    False
    False
    True
    True
    False

    Logical Operator

    There are three logical operators use in the python programming language. They are and, or and not. Further, the output of these operators is either True or False. The following table shows the syntax and description of these operands in detail.

    Logical Operator syntax and description
    Logical Operator

    The input variables of a logical operator are either True or False. The following code shows how logical operators are used in the python program.

    X=True
    Y=False
    print(X&Y)
    print(X or Y)
    print( not X)
    Output:
    False
    True
    False

    Bitwise Operators

    Bitwise operators are also the most useful operators in a python programming language. These operators perform the operation bit by bit. Additionally, there are different types of bitwise operators are used in practice. The following table depicts the syntax and description of bitwise operators.

    Bitwise Operators syntax and discription
    Bitwise Operators

    The following code shows the implementation of bitwise operators in a python programming language.

    a=10
    b=3
    print(a&b)
    print(a|b)
    print(~a)
    print(a^b)
    print(a>> b)
    print(a<<b)
    Output:
    2
    11
    -11
    9
    1
    80

    Assignment Operators

    On the other hand, assignment operators are used to assigning the value to the operand. There are different type of assign operators use in a programming language such as normal assignment, And add, And subtraction etc. following table show the syntax and description of different type of assignment operand in details.

    Membership operators

    These operators are used to check whether the value is present or not in a sequence of data. additionally, there is two types of membership operators are practised. In and not in are the type of membership operators. The output return by this operator is either True or False.  The following table shows the syntax and description of membership operators in detail.

    Membership  operators syntax and description
    Membership operators

    The following code shows how to use membership operators in a python programming language

    X=[1,2,4,3,5]
    print(2 in X)
    print(6 not in X)
    Output:
    True
    True

    Conclusion

    OK, this is the end of the article I hope you can get a good lesson from what I deliver in this article. I ask forgiveness for any word and behave which are not to be. Thank you for your kind and attention guys. Stay tuned for the next article. if you are searching for a free python course here is a link. If you have any questions regarding this article please feel free to comment below.

    install python python3
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

    Related Posts

    Python Functions

    September 14, 2020

    python Loop and Iteration

    September 13, 2020

    Python if else Statement

    September 10, 2020

    Python Variable and Data type

    August 30, 2020
    Add A Comment

    Leave A Reply Cancel Reply

    Recent Updates

    What is artificial intelligence and it’s applications

    April 26, 2022

    Data Visualization using Matplotlib

    November 23, 2021

    Pandas for Machine learning

    November 23, 2021

    NumPy array for machine leaning

    November 23, 2021

    Oops concepts in python with examples

    September 6, 2021

    Types of Operators in Python

    September 6, 2021

    Python Dictionary

    September 28, 2020
    © 2023 Returnscript.com | All Rights Reserved

    Type above and press Enter to search. Press Esc to cancel.