# Python program to find the power ‘n’ of the given number ‘a’

Hello everyone, welcome to nkcoderz.com. In this article we will going to discuss about Python program to convert GCD of the given 2 numbers.

C program to compute sin(x) using Taylor’s series

## Code for python program to find the power ‘n’ of the given number ‘a’

``````def power(a, n):
result = 1
for i in range(n):
result *= a
return result

# test the function
print(power(2, 3))
print(power(4, 2))
``````

`8`

16

## Explanation

The function `power(a, n)` takes in two parameters, `a` and `n`, and returns `a` raised to the power of `n`. It does this by using a for loop that iterates `n` times, and in each iteration, it multiplies `result` by `a`.

The initial value of `result` is set to 1 so that when the loop starts and the first time `a` is multiplied, it is multiplied by 1.

## Conclusion

If you liked this post, then please share this with your friends and make sure to bookmark this website for more awesome content.