## Operator Module in PythonIn this tutorial, we will learn about the operator module in Python and its various functions. We will use these functions of the operator module in a Python program to demonstrate their work. ## Python Operator ModuleAs the name suggests, the operator module performs various operations and operates two input numbers in a Python program. The Python operator module is one of the inbuilt modules in Python, and it provides us with a lot of functions such as add(x, y), floordiv(x, y) etc., which we can use to perform various mathematical, relational, logical and bitwise operations on two input numbers. We will learn about some of these functions of the operator module in this section and will use each of them in a Python program to understand their functioning. We have categorised the operator functions into categories according to their functioning. ## Mathematical Operation Functions:Here, we will look at some of the major operator functions we can use to perform mathematical operations such as addition, subtraction, division etc., on two input given values. Let's have a look at the following functions where we understand them in brief by using them in a program:
Operator module performs
Enter first integer number: 234 Enter second integer number: 729 Addition of input numbers given by you is: 963
Operator module performs
Enter first integer number: 727 Enter second integer number: 344 Subtraction of input numbers given by you is: 383
Operator module performs
Enter first integer number: 27 Enter second integer number: 23 Multiplication result of numbers given by you is: 621
Operator module performs
Enter first integer number: 25 Enter second integer number: 6 True division result of numbers given by you is: 4.166666666666667
Operator module performs
Enter first integer number: 25 Enter second integer number: 6 Floor division result of numbers given by you is: 4
Operator module performs
Enter first integer number: 17 Enter second integer number: 13 Result of modulus operation on numbers given by you is: 4
Operator module performs
Enter an integer number: 5 Enter power value for the integer number you gave: 5 Exponentiation result of power value of number given by you is: 3125 ## Relational Operation Functions:We will look at some more functions from the operator module, but these functions belong to the relational operation category. With these functions, we can establish a relationship between any two given input numbers such as smaller one, larger one, equal etc. Look at the following operator functions from relational category with the use of each of them in a Python program:
Operator module performs
Enter first integer number: 24 Enter second integer number: 26 Is first number given by you is smaller than the second number: True
Operator module performs
Enter first integer number: 23 Enter second integer number: 19 Is first number given by you is smaller or equal to the second number: False
Operator module performs
Enter first integer number: 38 Enter second integer number: 49 Is first number given by you is greater than the second number: False
Operator module performs
Enter first integer number: 23 Enter second integer number: 21 Is first number given by you is greater or equal to the second number: True
Operator module performs
Enter first integer number: 24 Enter second integer number: 26 Is both input numbers given by you are equal: False
Operator module performs
Enter first integer number: 7 Enter second integer number: 9 Is both input numbers given by you are not equal: True ## ConclusionIn this tutorial, we have discussed the operator module in Python and its various function with examples. |

For Videos Join Our Youtube Channel: Join Now

- Send your Feedback to [email protected]