Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator **=

Raises the stored value to the specified power and assigns the result to the same target.

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

Syntax

target **= value

Raises the stored value to the specified power and assigns the result to the same target.

Use this update when the old value is the base for the next power. Built-in integers raised to nonnegative integer powers retain integer precision.

The exponent is evaluated before the assignment finishes. Zero raised to a negative exponent raises a division exception and leaves an ordinary name bound to its original value.

A negative exponent can change an integer binding into a float.

Syntax

target **= value

__ipow__, __pow__, __rpow__ · ZeroDivisionError

Worked example

n = 2; n **= -2
n → 0.25

Examples

value = 2
value **= -3
print(value)
print(type(value).__name__)

Result

0.125
float

A negative exponent can change an integer binding into a float.

Sources