A fridge should keep food at a temperature between 0 and 5 degrees Celsius (inclusive). Assume you have a non-empty list of integer and/or floating-point numbers representing the hourly temperature readings, also in degrees Celsius. Print the list of all temperatures that are outside the allowed range. The answer box contains Pattern 2.3 (List filtering) as comments, to get you started. Write the corresponding code beneath each comment. Use variable names appropriate to the problem at hand instead of the generi
A fridge should keep food at a temperature between 0 and 5 degrees Celsius (inclusive). Assume you have a non-empty list of integer and/or floating-point numbers representing the hourly temperature readings, also in degrees Celsius. Print the list of all temperatures that are outside the allowed range.
The answer box contains Pattern 2.3 (List filtering) as comments, to get you started. Write the corresponding code beneath each comment. Use variable names appropriate to the problem at hand instead of the generic names used by the pattern. The first step has been done for you. It uses an operation we defined for you, get_input() , to obtain the list used by each test.
The list from get_input() is assigned to temperatures (which corresponds with the input_list in the pattern).
You do not have to understand or work out how get_input() works.
For example:
Input | Result |
---|---|
[4.7]
|
[]
|
[5.2]
|
[5.2]
|
[0, 3, 5, 7, 5, 4, 2, 0, -0.2]
|
[7, -0.2]
|
Star of code follows
Step by step
Solved in 5 steps with 3 images