Editor settings

General settings

Save settings

Learn to program with Python

Raise a number to a power #

In Python, the operator ** is used to raise a number to a power. The syntax for this operation is as follows:

base ** exponent

Here's an example:

# raise 2 to the power of 3
result = 2 ** 3
print(result)  # output: 8

# which is the same as
result = 2 * 2 * 2
print(result) # output: 8

Exercise #

  • Change the * operator to ** so that the value of variable x is 25
Output will be displayed here