How to find exponent of a number in Python?

0 votes
I am new to Python. I wish to write a function in python that calculates a square or a cube or any other power of a number? How to do it ?
Jul 2 in Python by Neel
• 3,010 points

1 answer to this question.

0 votes
Yes you can do it using the math library in Python

import math
x = math.pow(2,3) # x = 2 to the power of 3

You can include the above code in a function and then call the function.
answered Jul 2 by Arvind
• 2,960 points

Related Questions In Python

0 votes
2 answers

How to calculate square root of a number in python?


answered Apr 2 in Python by anonymous
–1 vote
2 answers

How to find the size of a string in Python?


answered Mar 29 in Python by rajesh
• 1,210 points
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?


answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 224 views
0 votes
2 answers


By using isAlpha () to check whether ...READ MORE

answered Jul 13 in Python by Sheik janibasha
0 votes
1 answer

How to find the type of variable in Python?

i=277 type(i) # int i = 2.56j type(i) # complex i ...READ MORE

answered Jul 16 in Python by Arvind
• 2,960 points