- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Inplace Operators - iadd(), isub(), iconcat()
In this article, we will learn about some of the inplace operators available in Python 3.x. Or earlier.
Python provides methods to perform inplace operations, i.e assignment and computation simultaneously using in a single statement with the help of “operator” module. Here we will discuss about ixor(), iand(), ipow() functions .
ixor()
This function allows us to assign and xor current value. This operation behaves like “a^=b” operation. Assigning can’t be performed in case of immutable data types, such as strings and tuples.
Example
import operator as op # using ixor() to xor int1 = op.ixor(786,12); # displaying value print ("The value : ", end="") print (int1)
Output
The value : 798
iand()
This function allows us to assign and bitwise& current value. This operation behaves like “a&=b” operation. Assigning can’t be performed in case of immutable data types, such as strings and tuples.
Example
# using iand() to bitwise& int2 = op.iand(57,34) print ("The value : ", end="") print (int2)
Output
The value : 32
ipow()
This function allows us to assign and exponentiate the current value. This operation behaves like “a**=b” operation. Assigning can’t be performed in case of immutable data types, such as strings and tuples.
Example
# using ipow() to exponentiate int2 = op.ipow(3,2) print ("The value : ", end="") print (int2)
Output
The value : 9
Conclusion
In this article, we learned about the usage and implementation of Inplace Operators in Python - ixor(), iand(), ipow().