beginnerPython
How does the exponentiation operator work?
Answer
Clear, interview-ready explanation
The exponentiation operator raises the left operand to the power of the right operand.
**
result = 2 ** 3
print(result)
Output:
8
This expression means:
2 × 2 × 2 = 8
A fractional exponent can be used to calculate roots:
square_root = 25 ** 0.5
print(square_root)
Output:
5.0