Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator **

Raises the left operand to the power on its right.

Version: Python 3.14; repository image, production runtime not attested

Syntax

left ** right

Raises the left operand to the power on its right.

Exponentiation associates from right to left. In a chain the rightmost power is therefore computed first, which matters when expressing exponential growth.

A negative exponent requires a nonzero base. Raising zero to a negative power fails; a negative real base with a fractional exponent can instead produce a complex result.

A negative integer exponent on a nonzero integer base can produce a fractional float.

Syntax

left ** right

__pow__, __rpow__ · ZeroDivisionError

Worked example

2 ** 3 ** 2 → 512
2 ** -2 → 0.25
0 ** -1 → ZeroDivisionError
isinstance((-1) ** 0.5, complex) → True

Examples

print(2 ** 5)
print(2 ** -3)

Result

32
0.125

A negative integer exponent on a nonzero integer base can produce a fractional float.

Sources