• **: exponentiation
  • ^: exclusive-or (bitwise)
  • %: modulus
  • //: divide with integral result (discard remainder)
Answer from John Zwinck on Stack Overflow
Top answer
1 of 3
198
  • **: exponentiation
  • ^: exclusive-or (bitwise)
  • %: modulus
  • //: divide with integral result (discard remainder)
2 of 3
45

You can find all of those operators in the Python language reference, though you'll have to scroll around a bit to find them all. As other answers have said:

  • The ** operator does exponentiation. a ** b is a raised to the b power. The same ** symbol is also used in function argument and calling notations, with a different meaning (passing and receiving arbitrary keyword arguments).
  • The ^ operator does a binary xor. a ^ b will return a value with only the bits set in a or in b but not both. This one is simple!
  • The % operator is mostly to find the modulus of two integers. a % b returns the remainder after dividing a by b. Unlike the modulus operators in some other programming languages (such as C), in Python a modulus it will have the same sign as b, rather than the same sign as a. The same operator is also used for the "old" style of string formatting, so a % b can return a string if a is a format string and b is a value (or tuple of values) which can be inserted into a.
  • The // operator does Python's version of integer division. Python's integer division is not exactly the same as the integer division offered by some other languages (like C), since it rounds towards negative infinity, rather than towards zero. Together with the modulus operator, you can say that a == (a // b)*b + (a % b). In Python 2, floor division is the default behavior when you divide two integers (using the normal division operator /). Since this can be unexpected (especially when you're not picky about what types of numbers you get as arguments to a function), Python 3 has changed to make "true" (floating point) division the norm for division that would be rounded off otherwise, and it will do "floor" division only when explicitly requested. (You can also get the new behavior in Python 2 by putting from __future__ import division at the top of your files. I strongly recommend it!)
🌐
W3Schools
w3schools.com › python › python_operators.asp
Python Operators
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... Operators are used to perform operations on variables and values. In the example below, we use the + operator to add together two values: ... Although the + operator is often used to add together two values, like in the example above, it can also be used to add together a variable and a value, or two variables:
🌐
freeCodeCamp
freecodecamp.org › news › python-do-while-loop-example
Python Do While – Loop Example
August 31, 2021 - The while loop, on the other hand, doesn't run at least once and may in fact never run. It runs when and only when the condition is met. So, let's say we have an example where we want a line of code to run at least once. secret_word = "python" counter = 0 while True: word = input("Enter the secret word: ").lower() counter = counter + 1 if word == secret_word: break if word != secret_word and counter > 7: break
🌐
Quora
quora.com › What-exactly-does-do-in-Python-1
What exactly does += do in Python? - Quora
Answer (1 of 6): These are known short hand of coding. They're common in most programming languages be it python, java, c/c++ and a few other… [code]x += {expression} # Is equivalent to x = x + ({expression}) [/code]Note the parentheses there? It's necessary! Check the example- [code]a = 5 a ...
🌐
Codecademy
codecademy.com › learn › introduction-to-python-dvp › modules › python-syntax-dvp › cheatsheet
Introduction to Python: Python Syntax Cheatsheet | Codecademy
An integer can be a positive number, a negative number or the number 0 so long as there is no decimal portion. The number 0 represents an integer value but the same number written as 0.0 would represent a floating point number. ... Python supports the joining (concatenation) of strings together using the + operator.
🌐
TestMu AI Community
community.testmuai.com › ask a question
What does += do in Python? - TestMu AI Community
October 10, 2024 - What exactly does += do in Python? I need to know the functionality of += in Python. It’s that simple. I would also appreciate links to definitions of other shorthand tools in Python, like python +=.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-operators
Python Operators - GeeksforGeeks
In Python programming, Operators in general are used to perform operations on values and variables. Operators: Special symbols like -, + , * , /, etc. Operands: Value on which the operator is applied.
Published   December 2, 2025
Find elsewhere
🌐
Sololearn
sololearn.com › en › Discuss › 2556728 › what-does-do-in-python
What does >> do in python? | Sololearn: Learn to code for FREE!
But actually I thought bitwise operators were absolutely faster than arithmetic operators, but it might be about Python that they always aren't. ... Those bitwise operators are really slow. Don't recommend using them. ... Seb TheS yeah, you are right. https://code.sololearn.com/cd0MA87cJj9L/?ref=app ... Shift right operation is equivalent to integer division by 2**nb_bits.
🌐
Real Python
realpython.com › python-operators-expressions
Operators and Expressions in Python – Real Python
January 11, 2025 - Free Bonus: Click here to download your comprehensive cheat sheet covering the various operators in Python. Take the Quiz: Test your knowledge with our interactive “Python Operators and Expressions” quiz. You’ll receive a score upon completion to help you track your learning progress: ... Test your understanding of Python operators and expressions. In programming, an operator is usually a symbol or combination of symbols that allows you to perform a specific operation.
🌐
Quora
quora.com › What-do-the-operators-and-do-in-Python-1
What do the operators +=, *=, /= and %= do in Python? - Quora
Answer (1 of 3): a += b , simply means a = a + b Similarly a*=b is equivalent to a = a*b and a%=b is equivalent to a = a%b Hope it helps…
🌐
Coursera
coursera.org › coursera articles › data › what is python used for? a beginner’s guide
What Is Python Used For? A Beginner’s Guide | Coursera
May 20, 2025 - Writing code used to build these automated processes is called scripting. In the coding world, automation can be used to check for errors across multiple files, convert files, execute simple math, and remove duplicates in data. Python can even be used by relative beginners to automate simple computer tasks—such as renaming files, finding and downloading online content, or sending emails or texts at desired intervals.
🌐
Sololearn
sololearn.com › en › Discuss › 1670344 › what-exactly-does-is-do-in-python
What exactly does "is" do in python? | Sololearn: Learn to code for FREE!
But not necessarily True if the compared values are of the same type. a = [1, 2, 3] b = list(a) print(type(a)) # <class 'list'> print(type(b)) # <class 'list'> print(a is b) # Fasle
🌐
DataFlair
data-flair.training › blogs › python-operator
Python Operator - Types of Operators in Python - DataFlair
July 12, 2025 - It checks if the value on the left of the operator is not equal to the one on the right. The Python operator <> does the same job, but has been abandoned in Python 3.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-do-while
Python Do While Loops - GeeksforGeeks
July 23, 2025 - Output: In the below output we can clearly see that program also prints "2 x 5=10" even though 5 is not less than 5. ... In this example, we are going to implement the do-while loop in Python using the while loop and if statement in Python and comparing the while loop with the do-while loop ...
🌐
Readthedocs
climada-python.readthedocs.io › en › latest › development › Guide_PythonDos-n-Donts.html
Coding in Python: Dos and Don’ts — CLIMADA 6.1.1-dev documentation
decorators (a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure). Something like: @uppercase_decorator def say_hi(): return "hello there" type checking (Python is a dynamically typed language; also: cf. “Duck typing”. Yet, as a best practice, variables should not change type once assigned) Do not use mutable default arguments in your functions (e.g.
🌐
Python.org
discuss.python.org › python help
What does ":" do in this line of code? - Python Help - Discussions on Python.org
July 18, 2023 - OK, if I do understand correctly “windows” class now have a “dictionary” and it has several “keys” assigned / defined · File “/mnt/RAID_124/PYTHON_TEST_PROJECTS_FOLDER/nanovna-saver-clean_CLONE-JULY18_version1/src/NanoVNASaver/NanoVNASaver.py”, line 320, in init “DTW”: ...