Find power of number in python by R4R Team

program take two number as input and our task is to find the power like

example -
a=2
b=3
ans=2 to the power 3
i.e 8

program -

#first way
a=input("Enter first numbern")
b=input("Enter second numbern")
a=int(a)
b=int(b)
ans=a**b
print("Power is - "+str(ans))

#second way
ans=pow(a,b)
print("Power is - "+str(ans))


output -

Enter first number
2
Enter second number
3
Power is - 8
Power is - 8


In this program, we find the power in two ways. In first way we use ** operator while in second way we use pow() function which take two argument and find the power a to the power b.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!