import math
x = math.pow(2,3) # x = 2 to the power of 3
1
votes
if you want to repeat it multiple times - you should consider using numpy:
import numpy as np
def cube(number):
# can be also called with a list
return np.power(number, 3)
print(cube(2))
print(cube([2, 8]))
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
**is exponential, but doing multiplication when you know the exponent (i.e.x*xandy*y*yinstead ofx**2andx**3) is faster. - Matthew