2**3**2= 512. Why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 13

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?

14th Aug 2020, 2:51 PM
Hasnij Udeh Obewu
Hasnij Udeh Obewu - avatar
27 Answers
+ 36
Right to left 2**3**2 == 2^(3^2) first 3**2 == 9 then 2**9 == 512
14th Aug 2020, 2:52 PM
Utkarsh Sharma
Utkarsh Sharma - avatar
+ 6
** 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 🙇🏻‍♂️
14th Aug 2020, 2:55 PM
Prasad Bankar
Prasad Bankar - avatar
+ 4
Cause python treat 2**3**2 as 2**3**2=2**9=512
16th Aug 2020, 8:11 AM
Samartha Bhatt
Samartha Bhatt - avatar
+ 4
*=multiplication **=power
16th Aug 2020, 1:41 PM
Devansh nandan
+ 2
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.
14th Aug 2020, 3:52 PM
Ore
Ore - avatar
+ 2
You can override the default order R-->L by using parentheses.... for exponentiation 🤔
16th Aug 2020, 5:32 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 2
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?
16th Aug 2020, 6:49 AM
nurieff``
+ 2
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
16th Aug 2020, 1:41 PM
Rahmataliyev Shohjahon
Rahmataliyev Shohjahon - avatar
+ 1
Himanshu Shah 4<sup>2</sup> is not 16. It is 4².
14th Aug 2020, 3:34 PM
Ore
Ore - avatar
+ 1
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.
14th Aug 2020, 3:44 PM
Ore
Ore - avatar
+ 1
Don't forget computer reads code from up to down and from right to left
15th Aug 2020, 2:11 PM
Merdan Atamyradow
Merdan Atamyradow - avatar
+ 1
you can also do this using the pow() function
15th Aug 2020, 5:28 PM
Flarenog
Flarenog - avatar
+ 1
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
16th Aug 2020, 6:34 AM
saraswathi manmi
saraswathi manmi - avatar
+ 1
2**3**2 is calculated as : ** Is an exponential operator So, first 3**2 is calculated which is 9 = 2**9 =512
16th Aug 2020, 7:29 AM
Neha M V
Neha M V - avatar
+ 1
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
16th Aug 2020, 9:57 AM
__k_maaz__ [ INACTIVE ]
__k_maaz__ [ INACTIVE ] - avatar
+ 1
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.
16th Aug 2020, 10:52 AM
Akpadja Israel
Akpadja Israel - avatar
+ 1
2**3**2 Square of 3 is 9 2**9 2⁹=512
16th Aug 2020, 1:37 PM
Ayush Gid
Ayush Gid - avatar
+ 1
That's equal to 2**9 which is equal to 512
16th Aug 2020, 1:38 PM
Sepideh Yousefi Azar
Sepideh Yousefi Azar - avatar
+ 1
2**3**2 3^2=9 2**9 (2^9) =512
16th Aug 2020, 1:43 PM
Astrid
Astrid - avatar
+ 1
In python, ** means 'to the power of'. So 2**3**2 = 2**9 (because 3^2 = 3x3 = 9). Then, 2**9 = 512 (because 2^9 = 2x2x2x2x2x2x2x2x2 = 512)
16th Aug 2020, 1:47 PM
Akuminla Aier
Akuminla Aier - avatar