# using pow() function
base = int(input("Enter the value for base :"))
exponent = int(input("Enter the value for exponent :"))
print(base,"to power ",exponent,"=",pow(base,exponent))
( OR )
# using for loop (iterative method)
base = int(input("Enter the value for base :"))
exponent = int(input("Enter the value for exponent :"))
power=1
for i in range(1,exponent+1):
power*=base
print(base,"to power ",exponent,"=",power)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter