Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python calculate the power of number

base = 3
exponent = -4

result = pow(base, exponent)

print("Answer = " + str(result))
Comment

python calculate the power of number

base = 3
exponent = 4

result = 1

while exponent != 0:
    result *= base
    exponent-=1

print("Answer = " + str(result))
Comment

calculating the power in python

the ** operator is used for power 

base ** exponent

example : 
  2 ** 4
same as : 
  2 * 2 * 2 * 2
equals : 
  16
Comment

python calculate the power of number

base = 3
exponent = 4

result = 1

for exponent in range(exponent, 0, -1):
    result *= base

print("Answer = " + str(result))
Comment

PREVIOUS NEXT
Code Example
Python :: how to implement heap in python 
Python :: convert to lwercase in df column 
Python :: compare dates in python 
Python :: pandas trim string of all cells 
Python :: image resolution extracting python 
Python :: python sh command 
Python :: index.py:14: RuntimeWarning: invalid value encountered in true_divide return np.dot(user, user2) / (norm(user) * norm(user2)) 
Python :: how to make python script run forever 
Python :: how to iterate a list in reverse order in python with index 
Python :: list in python 3 
Python :: python dictionary map function 
Python :: stock market python 
Python :: merge two arrays python 
Python :: trim strings python 
Python :: return variable python 
Python :: change excel value in python 
Python :: requirements.txt dev python 
Python :: python lock file 
Python :: python while variable is not 
Python :: create a flask app 
Python :: python cant remove temporary files 
Python :: python basics 
Python :: for in print 
Python :: DIF_GCD solution 
Python :: key pressed pygame 
Python :: python count elements in sublists 
Python :: geckodriver seleniunm setup 
Python :: pandas convert string to float 
Python :: sort function in pandas dataframe to sort specific properties 
Python :: how to delete a column in pandas dataframe 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =