Question: Within a Python file named recursion fun.py , write the following functions: ( a ) ( 4 points ) power ( b , n )

Within a Python file named recursion fun.py, write the following functions:
(a)(4 points) power(b, n)
Returns the value of bn for any numeric b and any integer n (including negative integers).
Do not use any loops, and do not use any built-in ways of computing powers. This function
must be recursive. Hint: this is extremely similar to the power 2 function that we wrote
in class.
(b)(4 points) count negatives(stuff)
Returns how many negative integers (i.e.,<0) are contained in stuff. You may assume
that stuff is a list of integers. Do not use any loops, and do not use any built-in ways of
searching a list. This function must be recursive.
(c)(4 points) all short(stuff)
Returns whether or not stuff contains only short strings. Well define a short string
as being 8 characters or less in length. If stuff is empty, this should return True. You
may assume that stuff is a list of strings. Do not use any loops, and do not use any
built-in ways of searching a list. This function must be recursive.
(d)(6 points) binary search(stuff, target)
Returns the index of target within the list stuff if it exists, or False if it doesnt exist.
You may assume that stuff is a sorted list of integers, and target is an integer. Do not
use any loops, and do not use any built-in ways of searching a list. This must be done
recursively; you can write a recursive helper function if needed.
(e)(6 points) After your function definitions in recursion fun.py, write some tests for your
functions. Each test should call the function with specific argument(s) and print the return
value. Be sure to test at least the following scenarios:
1

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!