# 2**3**2= 512. Why?

So I was doing one of the Python 3 lessons (Basic Concepts, Other Numerical Operations) and I reached the Exponentation point. I understand how you raise one number to the power of another, but how do chained exponentations work?

8/14/2020 2:51:05 PM

Hasnij Udeh Obewu30 Answers

New AnswerHasnij Udeh Obewu In Python Associativity is the order in which expression ( having multiple operators of same precedence ) is evaluated. Almost all the operators have left to right associativity except exponentiation (**) which has right to left associativity that means in case of multiple operators with same precedence other than **, in same expression - the operator on the left is evaluated first and then the operator on its right and so on That's why here we have to calculate the expression from the its right side 2**3**2 2**9 512 I hope you understood 🙂

** means raised to power so first we take 3**2 which is 3 square = 9 . Then we take 2**9 which is 2 power 9 which is 512 .Hope it helps 🙇🏻♂️

Himanshu Shah Whatever 🤦 Comparing Python to HTML is pointless and saying something wrong about HTML is misinformation. The time you are wasting arguing with me can be used to remove that misinformation from your answer. Good luck.

You can override the default order R-->L by using parentheses.... for exponentiation 🤔

x**y means x^y in cases like this x**y**z, you have to calculate from rigth to left, i mean x^(y^z) in your code 2^(3^2) = 2^9 = 512 is it clear?

In python power operator is ** . So in order to simplify expression we need to divide it into parts. 2**3=2^3, 3**2=3^2=9 => 2**3**2=2^(3^2)=2^9=512

Himanshu Shah Well, here is what I can see in your answer. <<< Eg. 4 <sup>2</sup> answer is 16. <<< That is not true. At least, for the majority of browsers it renders 4² not 16.

2**3**2=512 2 to the power 3 =2^3=8 Similarly 8 to the power 3 8^3=512 2^3=8 8^3=512

2**3**2 is calculated as : ** Is an exponential operator So, first 3**2 is calculated which is 9 = 2**9 =512

Because 2**3**2 = 2^(3^2) = 2^9 = 512 This is different from (2**3)**2 , which is (2^3)^2 = 8^2 = 64

Well I am at the Lambdas point and looking at this question, you use associativity property of operations. So:2**3**2=2**(3**2). "**" means exponent where the first number is the base and the other is exponent.So we get 2**9=512 In python the first number is the variable so other nunbers are placed in the brackets to be worked with, before the first number in the expression is used as the base. In short, (2**3)*2=64 which is wrong.