Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
operators
arithmetic
exponent

Power operator in Python

Educative Answers Team

Python has a number of basic operators including some arithmetic operators.

An arithmetic operator takes numerical values as an input and returns a single numerical value, manipulating the input values in a certain way as directed by the operator.


Power (exponent) operator

One important basic arithmetic operator, in Python, is the exponent operator. It takes in two real numbers as input arguments and returns a single number.



The operator that can be used to perform the exponent arithmetic in Python is **.

Given two real number operands, one on each side of the operator, it performs the exponential calculation (2**5 translates to 2*2*2*2*2).

svg viewer

Note: Exponent operator ** in Python works in the same way as the pow(a, b) function.


Examples

Here are some examples that show how to use the ** operator:

print('2**5 evaluates to: ', 2**5)

print('1**13 evaluates to: ', 1.1**13)

print('32**2 evaluates to: ' , 32**2.2)

RELATED TAGS

python
operators
arithmetic
exponent
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring