Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
What is the associativity of Python's ** operator?
From the Python docs:
Operators in the same box group left to right (except for comparisons), including tests, which all have the same precedence and chain from left to right — see section Comparisons — and exponentiation, which groups from right to left).
So the ** operator(exponentiation) is right to left associative. For example,
2 ** 3 ** 4 will be evaluated as: (2 ** (3 ** 4))
For example,
print(2 ** 3 ** 0)
This will give the output:
2
Advertisements
