Looking for Programming for Engineers || Spring25 test answers and solutions? Browse our comprehensive collection of verified answers for Programming for Engineers || Spring25 at elearn.squ.edu.om.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
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