Question
In python Write a function, larger_than_average(input_list), that returns the list of numbers in input_list that are greater than the average of the numbers earlier in
In python
Write a function, larger_than_average(input_list), that returns the list of numbers in input_list that are greater than the average of the numbers earlier in the list. The passed-in input_list will always contain at least one number. The result should never contain the first number, as there is no average of earlier numbers in the list. For example, if the list [1,3,5,2,4] is passed in, the function should return [3,5,4]. This is because at index 1 the average is 1, so 3 is added to the list to return. At index 2 the average is 2, so 5 is added. At index 3 the average is 3, so 2 is not added. At index 4, the average is 2.75, so 4 is added. Here are few examples that your function will be expected to produce: larger_than_average([1,3,5,2,4]) should return [3,5,4] larger_than_average([1]) should return [] larger_than_average([1,2,3,4,5]) should return [2,3,4,5]
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