Exponentiation in Python
There is also a special operator for raising a number to a power, **
. Let's use it to raise the number 10
to the third power:
print(10 ** 3) # 1000
Let's raise the value of the variable to a power:
num = 10
print(num ** 3) # 1000
It may be that both the number and the degree are contained in variables:
num1 = 10
num2 = 3
print(num1 ** num2)
Two numbers are given:
num1 = 2
num2 = 5
Raise the first number to the power of the second number.
Two numbers are given:
num1 = 1
num2 = 3
Raise the number 5
to the power equal to the sum of these two numbers.