Menu

[Solved]-Python Code Get Help Fixing Filter Map Functions Functools Import Reduce Scores 25 56 79 9 Q37179556

* This is my python code, can I get some help fixing my filter()and map() functions?

from functools import reduce

scores = [25, 56, 79, 94, 99]
print(“Initial scores are: ” + str(scores))

total_scores = reduce(lambda a,b : a+b,scores)

average = total_scores/len(scores)
print(“Sum of all scores: ” + str(total_scores))
print(“Average: ” + str(average))

# use filter to figure scores that are above average
above_avg = filter(lambda x: x > average, average)
print(“Scores above average: ” + str(list(above_avg)))

curved_scores = map(lambda x, x + 5, scores) #map the scores listby adding 5 to each item in the list
print(“Curved scores are: ” + str(list(curved_scores)))

Expert Answer


Answer to * This is my python code, can I get some help fixing my filter() and map() functions? from functools import reduce score… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *