Account
Categories

Exponent AND Assign Operator


Definition:

The Exponent AND Assign Operator (**=) is used to raise a variable to the power of a value and store the result in the same variable.

It takes the value on the left side, raises it to the power of the value on the right side, and saves the result in the same variable.

Syntax:

variable **= value

Example:

x = 2
x **= 3  # raises x to the power 3
print(x)

Output:

Exercise

Use the Exponent AND Assign Operator to raise the value of a to the power of b where a = 4 and b = 4, then print the result using Python.