Question: 3 . Implement put _ in Read the specification of the function put _ in in the module funcs. Implement this function according to its

3. Implement put_in
Read the specification of the function put_in in the module funcs. Implement this function according to its specification. You are not allowed to use any loops or recursion in this function. Instead, you should complete the function using list methods alone.
Note that the function put_in should not return anything. In fact, the test cases in tests.py check both the argument (which should be modified) and the return value (ensuring that it is None). When you have implemented the function, test your answer with the test script before moving on to the next function.
def put_in(alist,value):
"""
Adds a value to a sorted list, resorting as necessary.
Examples:
If a =[0,2,3,4], put_in(a,1) makes a =[0,1,2,3,4]
If a =[0,2,3,4], put_in(a,2) makes a =[0,2,2,3,4]
If a =[], put_in(a,3) makes a =[3]
Parameter a: The list to append to
Precondition: a is a sorted list of a single type of element
Parameter value: The value to append
Precondition: value has the same type as the elements of a
"""
pass

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 Databases Questions!