What is the result of the expression 2 ** 3 in Python?

The story behind the answer

The result of the Python expression 2 ** 3 is 8. The double-asterisk operator means exponentiation, so the expression raises 2 to the third power: 2 × 2 × 2.

Python uses ** for powers rather than the caret symbol (^). In Python, ^ is the bitwise exclusive-OR operator, so writing 2 ^ 3 does not calculate a power. The built-in pow(2, 3) produces the same numerical result, and pow(2, 3, modulus) can efficiently calculate a modular power.

Exponentiation has higher precedence than ordinary addition and subtraction, so 2 + 3 ** 2 is evaluated as 2 + 9, giving 11. Parentheses can change the order explicitly. Python also supports negative and fractional exponents: 2 ** -1 equals 0.5, while 9 ** 0.5 produces a floating-point square root.

A subtle detail is that exponentiation associates from the right. Thus, 2 ** 3 ** 2 means 2 ** (3 ** 2), or 512, rather than (2 ** 3) ** 2.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: