Question: python3 (2a) Write a function middle which takes a list L as its argument and returns the item in the middle position of L, when

python3

(2a) Write a function middle which takes a list L as its argument and returns the item in the middle position of L, when L has an odd length. Otherwise, middle should return 999999. For example, calling middle([8, 0, 100, 12, 18]) should return 100. You should, at least, have five different lists to test in the docstring: lists of even and odd number of numeric elements, lists of even and odd number of string elements, and a blank list. (Hint: you may use the // integer division operator).

(2b) Write a function, mySum, with one parameter, L, a list of numbers. mySum returns the sum of the numbers in the input list. (mySum should not use Pythons builtin sum function.) For example,

>>> mySum([2, 3, 2]) 7

In the docstring, there should be minimally five examples of function calls including a blank list, a single element list, and list of positive and negative numbers.

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!