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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started