Question: Write a program named powers.py that reads user input for two integers a andb, then computes and displays the value of ab . Assume that
Write a program named powers.py that reads user input for two integers a andb, then computes and displays the value of ab Assume that both a and b are nonnegative.Sounds pretty easy, right? The catch here is that you cannot use Pythons operator,or any other builtin way of finding powers. Instead, compute the result by repeatedlymultiplying a times a times times a for b times. Your code should work for any nonnegative valuesof a and b including zero. Remember that anything to the th power is Hint: Create a variable to store the result, and initialize it to Then write a loop thatrepeats b times. Each iteration multiplies the result by a
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
