logo

Crowdly

Browser

Add to Chrome

Programming for Engineers || Spring25

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:

  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
View this question
When you design an algorithm, it should be general enough to provide a solution to many problem instances, not just one or a few of them.
100%
0%
View this question
To get a better understanding of how recursion works, it is helpful to trace its calls.
100%
0%
View this question
When a call returns or completes its execution, the memory for the stack frame is reallocated.
0%
100%
View this question
When using functions that have default arguments, the required arguments must be provided and must be placed in the same positions as they are in the function definition's header.
100%
0%
View this question
The use of a common pool of data allows a program to grow easily as new data sources are added to the program.
0%
0%
View this question
The first five numbers of the Fibonacci sequence are 1 3 5 8 13.
0%
0%
View this question
The amount of memory needed for a loop grows with the size of the problem's data set.
0%
0%
View this question
Smart compilers exist that can optimize some recursive functions by translating them to iterative machine code.
100%
0%
View this question
The assignment of roles and responsibilities to different actors in a program is also called responsibility-driven design.
0%
0%
View this question

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