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 variablexis25
Getting Started with Python
Data Types
Python Functions
Statements in Python
Basic Debugging in Python
Basic Algorithm
Object-Oriented Programming
Error Handling
Intermediate Algorithm
Python Modules