Problem D
Remove Outliers
Write two functions for removing the minimum number and the maximum number from integer lists:
-
without_outliers(a_list):
Returns a new list. Does not modify the list passed as an argument. -
remove_min_and_max(a_list):
Returns nothing, modifies the list passed as an argument.
The main file, which handles input and output, is already provided. - Please only submit your function definitions, without any code outside the functions!
Input
Each of the functions should accept one list
In the samples below, the input consists of one line
containing a sequence
In the tests,
Output
The function without_outliers()
should return a new list
The function remove_min_and_max()
should return nothing (just None),
but should modify the given list
In each test case, the autograder will call both of the functions with the given list as a parameter, in sequence, and will verify the results as well as the effects on the given list, and print the following four lines to the output, as seen in the samples below:
-
“Original list before calling functions: {
}” -
“Resulting list after extracting middle: {
}” -
“Original list after extracting middle and before removing outliers: {
}” -
“Original list after removing outliers: {
}”
Sample Input 1 | Sample Output 1 |
---|---|
21 1 23 102 |
Original list before calling functions: [21, 1, 23, 102] Resulting list after extracting middle: [21, 23] Original list after extracting middle and before removing outliers: [21, 1, 23, 102] Original list after removing outliers: [21, 23] |
Sample Input 2 | Sample Output 2 |
---|---|
5 4 3 2 1 0 |
Original list before calling functions: [5, 4, 3, 2, 1, 0] Resulting list after extracting middle: [4, 3, 2, 1] Original list after extracting middle and before removing outliers: [5, 4, 3, 2, 1, 0] Original list after removing outliers: [4, 3, 2, 1] |
Sample Input 3 | Sample Output 3 |
---|---|
3 9 5 1 6 8 |
Original list before calling functions: [3, 9, 5, 1, 6, 8] Resulting list after extracting middle: [3, 5, 6, 8] Original list after extracting middle and before removing outliers: [3, 9, 5, 1, 6, 8] Original list after removing outliers: [3, 5, 6, 8] |
Sample Input 4 | Sample Output 4 |
---|---|
9 2 3 6 1 8 7 |
Original list before calling functions: [9, 2, 3, 6, 1, 8, 7] Resulting list after extracting middle: [2, 3, 6, 8, 7] Original list after extracting middle and before removing outliers: [9, 2, 3, 6, 1, 8, 7] Original list after removing outliers: [2, 3, 6, 8, 7] |