Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do Exercise 6.4 from your textbook using recursion and theis_divisiblefunction from Section 6.4. Your program may assume that both arguments tois_powerare positive integers. Note that

Do Exercise 6.4 from your textbookusing recursionand theis_divisiblefunction from Section 6.4. Your program may assume that both arguments tois_powerare positive integers. Note that the only positive integer that is a power of "1" is "1" itself.

After writing youris_powerfunction, 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))

You should submit a script file and a plain text output file (.txt) that contains the test output. Multiple file uploads are permitted. Dont forget to include descriptive comments in your Python code.

Your submission will be assessed using the following Aspects.

Does the submission include theis_divisiblefunction from Section 6.4 of the textbook?

Does the submission implement anis_powerfunction that takes two arguments?

Does theis_powerfunction callis_divisible?

Does theis_powerfunction call itself recursively?

Does theis_powerfunction include code for the base case of the two arguments being equal?

Does theis_powerfunction include code for the base case of the second argument being "1"?

Does the submission include correct output for the five test cases?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions