ProgrammingModerateInfosys · Accenture · Capgemini pattern
What is printed?
What is printed?
print(2 ** 3 ** 2)
- A. 72
- B. 4096
- C. 512
- D. 64
Correct answer: C. 512
** is right-associative: 2 ** 3 ** 2 = 2 ** (3 ** 2) = 2 ** 9 = 512. Reading it left to right, (2 ** 3) ** 2 = 64, is the trap.
More Python Programming questions
- What is printed? python print(-7 // 2, -7 % 2)
- What is printed? python a = [1, 2, 3] b = a b += [4] print(a)
- What is printed? python print(bool("False"), bool(""), bool(0.0))
- What is printed? python nums = [3, 1, 2] print(nums.sort())
- What is printed? python print([x x for x in range(5) if x % 2])
- What is printed? python s = "hello" print(s[::-2])