Power function : Function Define « Function « Python






Power function

Power function
 

def power(x, n):
    if n == 0:
        return 1
    else:
        return x * power(x, n-1)


print power(2,7)
           
         
  








Related examples in the same category

1.A function definitionA function definition
2.Define simple function in PythonDefine simple function in Python
3.A function that writes the Fibonacci series to an arbitrary boundaryA function that writes the Fibonacci series to an arbitrary boundary
4.Define a function in PythonDefine a function in Python
5.Function call
6.Factorial functionFactorial function