CBSE Class 11 Computer Science Question 118 of 173

Data Handling — Question 7

Back to all questions
7
Question

Question 5b

What will be output produced by following code? State reason for this output.

a = 5 - 4 - 3
b = 3**2**3  
print(a)     
print(b)     

Answer

Output
-2
6561
Explanation

    a = 5 - 4 - 3
⇒ a = 1 - 3
⇒ a = -2

The exponentiation operator (**) has associativity from right to left so:

    b = 3**2**3
⇒ b = 3**8
⇒ b = 6561

Answer