Python has several additional standard library methods for mathematical operations such as arithmetic, logical, relational, bitwise, and so on. Operations. These methods can be found in the operator module.
To use it, we first need to import it into the operator's standard library module.
In this section we will see some operator functions for bitwise and container operations.
First, we will see arithmetic control functions. It's like below.
# Arithmetic Operators import operator print ( 'Add:' + str (operator.add (56, 45))) print ('Subtract:' + str (operator.sub (56, 45))) print ('Multiplication:' + str (operator.mul (56 , 45))) print ('True division:' + str (operator.truediv (56, 45))) # same as a / b print ('Floor division:' + str (operator.floordiv (56, 45)) ) #same as a // b print ('Mod:' + str (operator.mod (56, 45))) #same as a% b print ('pow:' + str (operator.pow (5, 3) ))
Add: 101 Subtract: 11 Multiplication: 2520 True division: 1.2444444444444445 Floor division: 1 Mod: 11 pow: 125
The operator module also contains relational operators such as & lt ;, & lt; =, & gt;, & gt; =, == ,! =.
Operator functions as below &
# Relational Operators import operator print ('Less Than:' + str (operator.lt (5, 10))) print ('Less Than Equal:' + str (operator.le (10, 10))) print ('Greater Than:' + str (operator.gt (5, 5 ))) print ('Greater Than Equal:' + str (operator.ge (5, 5))) print ('Equal to:' + str (operator.eq (12, 12))) print ('Not Equal to : '+ str (operator.ne (15, 12)))
Less Than: True Less Than Equal: Tr ue Greater Than: False Greater Than Equal: True Equal to: True Not Equal to: True
R for Everyone: Advanced Analytics and Graphics. ...
ig Data applications are growing very rapidly around the globe. This new approach to decision making takes into account data gathered from multiple sources. Here my goal is to show how these diverse s...
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems PDF, 2nd Edition. This book assumes you know next to nothing about m...
This book is an indispensable guide focuses on Machine Learning and R Programming, in an instructive and conversational tone which helps them who want to make their career in Big Data Analytics/ Data ...