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, 2019 in Python by Neel
• 3,020 points
2,305 views

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
print(x)

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

Related Questions In Python

0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2, 2019 in Python by anonymous
5,857 views
–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

answered Mar 29, 2019 in Python by rajesh
• 1,270 points
2,106 views
–1 vote
2 answers
+1 vote
1 answer
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
0 votes
2 answers

How to check whether a string contains alphabets or number in Python?

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

answered Jul 14, 2019 in Python by Sheik janibasha
5,385 views
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, 2019 in Python by Arvind
• 3,050 points
899 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP