- 20
Print(2**3**2).?
answer is 512 ...?how it is 512..?
10 odpowiedzi
+ 8
Left to right precedence is fine. But there are other rules also, such as
2 pow (3 pow 2)
You cannot calculate power of 2 until 3 pow 2 evaluates to a number. So, it needs to be evaluated first.
+ 11
2**3**2
2 pow (3 pow 2)
2 pow 9
512
+ 4
bit confused there @Vega
8**2 is 64
what happenens in the print is as follows:
let's define two events, a and b
a is 3**2
b is 2**a
b a
2**(3**2)
a is evaluated first to give us 3 to the power of 2 and returns 9
a=3**2=9
then b is evaluated as 2 to the power of a ro give us 2 to the power of 9 which returns as 512
b=2**9=512
+ 4
"Operators in the same box group left to right (except for exponentiation, which groups from right to left)."
https://docs.python.org/3/reference/expressions.html#operator-precedence
That means, a**b**c evaluates to a**(b**c).
+ 2
try writing it like this (2**3)**2 and see what happens ;)
+ 1
we have to done from left to Right..this operation.right..?then y we take first 3**2
0
very helpful. Thank you
0
2*3**3*4???
0
What is the output of the following? * x = 36/4* (3 + 2) * 4+2
print(x)
- 7
help with the output
print( (3**2)//2 )