How can this code solve 2**3**2 to give 512 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can this code solve 2**3**2 to give 512

Python

19th Sep 2020, 1:41 PM
Muhammad Abdulmalik
Muhammad Abdulmalik - avatar
3 Answers
+ 3
3**2=9 so 2**9 is equal to 512
19th Sep 2020, 1:46 PM
Abhay
Abhay - avatar
+ 1
exponenents are calculated first in python, so youd have to say this (2**3)**2 == 64
19th Sep 2020, 1:44 PM
Jacob
Jacob - avatar
+ 1
print(2**3**2) is samsme as print(2**(3**2)) =512 Associativity is right to left for exponent.
19th Sep 2020, 4:43 PM
Jayakrishna 🇮🇳