logo

Crowdly

Browser

Додати до Chrome

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

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на elearn.squ.edu.om?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome