logo

Crowdly

Write a Python program that performs the following tasks inside a main() func...

✅ 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:

  1. Create a list named sensorReadings with the values [500, 1200, -50, 450, 800, 100].

  2. Use filter() to select only the readings between 0 and 1000 inclusive.

  3. Use map() to square each of the valid readings.

  4. Use reduce() to calculate the sum of the squared readings.

  5. Calculate the average of the squared readings.

  6. 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(), and reduce() 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
More questions like this

Want instant access to all verified answers on elearn.squ.edu.om?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome