Write four functions: (IN PYTHON 3)
1) bound(l) - given a list of integers l, compute a tuple containing the minimum and maximum values (in that order)
2) span(l) - given a list of integers l, compute the difference between the minimum and maximum function.
3) mean(l) - given a list of integers l, compute the average. The return value will be a float.
4) stats(f, l) - given a function f and a list l, apply the function f to the list and return the result.
This receives a list l as parameter, and finds the minimum and maximum of the list and return the tuple of it.
This can be written as:
# bound(l) - given a list of integers l, compute a tuple containing the minimum and maximum values (in that order)
def bound(l):
# get minimum of the list
minimum = min(l)
# get maximum of the list
maximum = max(l)
# return the tuple containing the minimum and maximum values
return (minimum, maximum)
Below is the sample output:

This function receives a list and find the minimum and maximum of the list like the above function. Then it calculates the difference between maximum and minimum and return that value.
This could be coded as:
# span(l) - given a list of integers l, compute the difference between the minimum and maximum function.
def span(l):
# get minimum of the list
minimum = min(l)
# get maximum of the list
maximum = max(l)
# calculate the difference between maximum and minimum
diff = maximum - minimum
# return the difference
return diff
Below is the sample output:

This function receives a list and calculate the mean of numbers of list and returns it. To calculate the mean, we iterate through the list and calculate the total of all value, then divide that value by the length of list, which will give the mean and then it returns it.
This could be coded as:
# mean(l) - given a list of integers l, compute the average. The return value will be a float
def mean(l):
# calculate the total of items
total = 0
for item in l:
total += item
# get size of list
size = len(l)
# calculate the average by dividing the total by size of list
average = float(total/size)
# return the average
return average
Below is the sample output:

This function receives another function and a list as a parameter. It calls the given function with list as its parameter. It returns the return value returned by the function f. It basically can be used to call above functions as its parameter.
This could be coded as:
# given a function f and a list l, apply the function f to the list and return the result
def stats(f, l):
# get value out of function
value = f(l)
# return the value which the return value of the respective function
return value
Below is the sample output:

All the required functions have been coded and explained above. Let me know if you have any queries.
Thanks!
Write four functions: (IN PYTHON 3) 1) bound(l) - given a list of integers l, compute...
Test CASE:
DATA1 = [1, 2, 3, 4, 5, 6]
DATA2 = [i for i in range(100) if i % 3 == 0]
assert(stats(span, DATA1) == 5)
assert(stats(mean, DATA1) == 3.5)
assert(stats(bound, DATA2) == [0, 99])
Write four functions: 1) bound() - given a list of integers 1, compute a tuple containing the minimum and maximum values (in that order) 2) span() given a list of integers 1, compute the difference between the minimum and maximum function 3) mean() given...
1 write a Python function that takes in a list of integers and returns maximum and minimum values in the list as a tuple. Hint (can be done in one pass, you are not allowed to use built-on min and max functions.)max, min = find_max_min(my_list):2 write a Python function that takes in a list of integers (elements), and an integer number (num). The functions should count and return number of integers in elements greater than, less than, and equal to...
Python recursive function:
Given an ordered list L. A permutation of L is a rearrangement of its elements in some order. For example (1,3, 2) and (3, 2, 1) are two different permutations of L=(1,2,3). Implement the following function: def permutations (lst, low, high) The function is given a list 1st of integers, and two indices: low and high (lows high), which indicate the range of indices that need to be considered The function should return a list containing all...
Use the FDR to design and write a function, maxValTimes, that takes a list of integers and returns a set containing the value(s) that occur the same number of times as the maximum value in the list. If the list is empty, return an empty set. For example if the list was [2,1,1,2,3,3,1] the function would return {2,3} as the maximum value is 3 which occurs twice, and 2 also occurs twice (but 1 occurs 3 times). For full marks,...
ON PYTHON: ''' Design the functions described below. RECALL: With functions that do not return a value and print a result to the console, to test you must call the function, run it and visually inspect the result for correctness. With functions that return a value, use the print_test function to provide feedback of the test results at the command line. The print_test function is implemented for you at the bottom of this file. RECALL: floating point arithmetic can lose...
In PYTHON: Write a function that receives a list of integers and returns the number of integers that are larger than the element immediately before them. For example, given [1,2,3,-5,0,-5,-10] the function should return 3 (since 1<2, 2<3, and -5<0).
Using Python. Write a function clean2(aList) that takes a list of integers aList as argument, and modifies this list, such as multiple occurrences of values have been removed. The procedure does not return a list: it modifies its argument (reference aList). 3 For instance, the following statements: al = [1,2,3,4,4,4,5,1,2,1,5] print(al) clean2(al) print(al) print the following result (a different order of values is acceptable): [1,2,3,4,4,4,5,1,2,1,5] [1,2,3,4,5]
2. Write a program with three functions that will be called from the main function The functions will calculate the volume, area and perimeter of a cuboid. You should able to pass three parameters such as length, width and height, and a function will return area, another will return volume and final one will return perimeter. Define all your variables in floating point numbers 3. Modify the problem#2 to calculate the volume, area and perimeter in a sing le function...
Write function all_coprime_pairs( ) which takes as input a list, L, with positive unique integers (i.e. no duplicated integers), and should return: 1. List (of tuples) containing all pairs of numbers in L that are coprime. 2. Empty list, If no pair of numbers in L is coprime. Your solution must include a function call to the function coprime designed in the previous question. The order of the tuples or the order of the two numbers within the tuples is...
Python Write a function named minGap that takes in a list of integers and returns the minimum ‘gap’ between values in the list. The gap between two adjacent values in a list is defined as the second value minus the first value. For example, suppose we have the following list: [1, 3, 6, 7, 12] The first gap is between indices 0 and 1 and its value is 3 − 1 = 2. The second gap is 6 − 3...