IPO Practice 4: Drop Lowest Quiz Score and Average
Goal:
Write two functions that work together to drop the lowest score from a list (without changing the original list) and then compute the average of the remaining scores.
Requirements:
1. Define a function drop_lowest(scores) that:
- Takes a list of numbers (scores).
- Returns a NEW list with exactly one instance of the lowest score removed.
- Does NOT modify the original list (no in-place changes).
- If there are multiple copies of the lowest score, remove only one of them.
- Assumes there are at least 2 scores.
2. Define a function average_without_lowest(scores) that:
- Takes a list of numbers (scores).
- Calls drop_lowest(scores).
- Returns the average (as a float) of the returned list.
- Assume there are at least 2 scores.
Using built-ins like min(), sum(), and len() is allowed, or you can use loops to do those tasks.
Examples (expected behavior):
drop_lowest([88, 92, 75, 100, 83]) -> [88, 92, 100, 83] average_without_lowest([88, 92, 75, 100, 83]) -> 90.75 drop_lowest([10, 9, 8, 7, 10]) -> [10, 9, 8, 10] average_without_lowest([10, 9, 8, 7, 10]) -> 9.25
Starter code – you may use these test lists, but the functions should work for any list with 2+ scores that is passed as a parameter.
scores1 = [88, 92, 75, 100, 83] scores2 = [10, 9, 8, 7, 10]
After you write your functions, try:
print(drop_lowest(scores1)) print(average_without_lowest(scores1)) print(drop_lowest(scores2)) print(average_without_lowest(scores2))