Question 6
Back to Exercise
What is the output of the following Python program?
def p(b, e):
return 1 if e == 0 else b * p(b, e - 1)
print(p(2, 10), p(5, 0), p(-3, 3))
- A 1024 1 -27 Correct
- B 1024 0 -27
- C 20 1 -9
- D 1024 1 27
Correct Answer: Option A
Anything to the power 0 is 1; (-3)³ = -27.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!