Question: Part B None of the solutions requires a loop. Your solutions can use: the [ ] operator to get and set list elements ( e
Part B
None of the solutions requires a loop.
Your solutions can use:
the operator to get and set list elements eg a lsti and lsti a;
the in and not in operators eg a in lst;
the list concatenation operator eg lst lst;
the list replication operator eg lst or ;
the del operator eg del lst;
Python's builtin len, min and max functions.
Your solutions cannot use:
for or while loops;
list slicing eg slice lsti : j or lsti : j t;
Python's builtin sum, reversed and sorted functions;
any of the methods provided by type list; eg append, clear, copy, count, extend, index, insert, pop, remove, reverse and sort;
list comprehensions which aren't covered in the textbook or ECOR
Exercise
Use the function design recipe from Chapter of Practical Programming to develop a function named middleway. The function takes two lists that each contain three integers; in other words, the function has two parameters, both parameters are lists, and both lists contain three integers. The function returns a new list containing the middle elements from both lists. For example, when the arguments are and the function returns
Your function definition must have type annotations and a complete docstring. Use the Python shell to test middleway.
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
