✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Write a Python program that performs the following tasks inside a main() function:
Create a list named sensorReadings with the values [500, 1200, -50, 450, 800, 100].
Use filter() to select only the readings between 0 and 1000 inclusive.
Use map() to square each of the valid readings.
Use reduce() to calculate the sum of the squared readings.
Calculate the average of the squared readings.
Print the following:
The original sensor readings.
The valid readings after filtering.
The squared readings.
The average of the squared readings.
Notes:
You must use the built-in functions
filter(),map(), andreduce()with use of lambda expression.Organize your code so that all steps are implemented inside a
main()function.Make sure to call
main()
Expected Output:
Original Sensor Readings: [500, 1200, -50, 450, 800, 100] Valid Readings: [500, 450, 800, 100] Squared Readings: [250000, 202500, 640000, 10000] Average of Squared Readings: 275625.0