Get Instant Help From 5000+ Experts For

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Python Function Exercises: Remove, Average, Maximum, Comparison and Sorting

Problem 1

Create a function, called remove_the_fact, which takes in a list of strings. We want you to remove the string of “fact” from the list and create a new list with all of the other strings. We want you to keep track of how many strings of “fact” were in the original list also. You will return a new list with position 0 being the total number of times we saw “fact”, and in position 1 we want the list of all the strings that are not “fact”. Review the template below with all information needed. You will start writing these functions for yourself moving forward.

Create a function, average_of_ints, which takes in a list that contains different types of objects including ints. You will calculate the average of all the ints on the list and return a list that contains in the 0th index position, the average of the ints and in t he 1st index position a list of the ints themselves. If the list is empty or there are no ints on the list, you will return the list [0, [ ]]. The average should be rounded and then forced to be an int. Ensure the average is always a whole number.

Write a function, called max_of_lists, that returns the maximum value in a list of lists. You can assume that the lists will have numerical values. You cannot use built in functions that return a max of a list. We want you to write the code to do this work. You will have no embedded lists inside of the list elements at the highest level. For example, you will not see [1, [1, [3]], 4] If the list that is passed in is the empty list, return a 0.

Write a function called, called greater_than. This function will take in a list and a numeric value and the function will return True if everything on the list that is numerical is greater than the value and False otherwise. Assume the list contains only ints, floats, and strings. You must write the code to do the comparisons and manipulations.

Sorting a list of objects “in place” (without the use of an additional list structure) is an important Computer Science problem that has been extensively studied. One of the simplest methods is known as selection-sort. The selection-sort algorithm is relatively easy to understand and implement, however it is not very efficient because it takes roughly n 2 operations on a list with n elements.

The selection-sort algorithm is as follows:

Given a list of integers, e.g. [3, 5, 2, 8, 9, 1], determine the smallest element in the list and swap it with the first element, then repeat the process for the remaining elements in the list. When you've completed the entire list, it will be sorted in ascending order of value [1, 2, 3, 5, 8, 9]. But we are going to do this with a twist. We are going to sort starting at the back instead of the front.

The selection-sort algorithm with a twist is as follows:

Given a list of integers, e.g. [3, 5, 2, 8, 9, 1], determine the largest element in the list and swap it with the last element on the list, then find the 2nd largest element and swap it with the 2nd to the last element on the list, then repeat the process for the remaining elements in the list. When you've completed the entire list, it will be sorted in ascending order of value [1, 2, 3, 5, 8, 9]: