![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
What does these operators mean (** , ^ , %, //) ?
In Python ** is a raised to operator. It returns x raised to y in the expression x**y
>>> x=5 >>> y=3 >>> x**y 125
^ is a bitwise XOR operator. Taking two bits as operands it returns 1 if one is 1 and other is 0
>>> a=10 >>> bin(a) #0001 1010 '0b1010' >>> b=20 >>> bin(b) #0010 0100 '0b10100' >>> c=a^b >>> c 30 >>> bin(c) #0011 1110 '0b11110'
// is defined as floor division operator. It returns integer part of result of division operation
>>> 10/3 3.3333333333333335 >>> 10//3 3
For negative division, floor rounds towards negative infinity.
>>> -10/3 -3.3333333333333335 >>> -10//3 -4
% symbol is defined as modulo operator and returns remainder of division operation.
>>> 10%3 1 >>> 10%2 0
In case of negative division difference bewen upper multiple and numerator is calculated
>>> -10%3 2 >>> -5%2 1 >>> 73%9 1 >>> -73%9 8
Advertisements