Question: Please code the following A number, a, is a power of b if it is divisible by b and a/b is a power of b.

Please code the following

A number, a, is a power of b if it is divisible by b and a/b is a power of b. Code a function called is_power that takes parameters a and b and returns True if a is a power of b. Note: you will have to think about the base case.

After writing your is_power function, include the following test cases in your script to exercise the function and print the results: print("is_power(10, 2) returns: ", is_power(10, 2)) print("is_power(27, 3) returns: ", is_power(27, 3)) print("is_power(1, 1) returns: ", is_power(1, 1)) print("is_power(10, 1) returns: ", is_power(10, 1)) print("is_power(3, 3) returns: ", is_power(3, 3))

Don't forget to include descriptive comments in your Python code so I can understand and follow whats going on.

Please use the checklist below to see that you did everything

  1. Does the submission include theis_divisiblefunction ?
  2. Does the submission implement anis_powerfunction that takes two arguments?
  3. Does theis_powerfunction callis_divisible?
  4. Does theis_powerfunction call itself recursively?
  5. Does theis_powerfunction include code for the base case of the two arguments being equal?
  6. Does theis_powerfunction include code for the base case of the second argument being "1"?
  7. Does the submission include correct output for the five test cases?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!