Question: We will be implementing menu item number 3 ( Edit room filter ) from the menu. Lists and Dictionary This module uses the two lists

We will be implementing menu item number 3(Edit room filter) from the menu.
Lists and Dictionary
This module uses the two lists (sensor_list & filter_list) and a dictionary (sensors) that we created in previous assignments. Ensure that the recursive_sort() function is also included in this module. The recursive_sort() function definition should be at the top of the module with the other function definitions. The lists and dictionary should come just before the while loop that runs the menu in main().
sensor_list
The list, sensor_list has information (room number, description, sensor number) about each sensor (sorted by room number). It is static (it is not changed). Place this list within main().
filter_list
The list filter_list will initially contain all sensor numbers from sensor_list. It will be updated by the function change_filter as the user makes changes to which sensors are active. It is a dynamic list. Place this list within main().
sensors
The dictionary, named sensors contains the room name, the room number, and sensor number from sensor_list. It is a dict. When the user enters a room number, we will use this dictionary to find the sensor number. It will stay static. Place this list within main().
Functions
print_filter
We need a function that will print the list of filters, and display which ones are currently active. Name this function print_filter(), print_filter should take two arguments, sensor_list and filter_list. It doesn't return anything since its sole job is to print to the screen.
change_filter,
The function change_filter() should take three required arguments: sensors, sensor_list, and filter_list. It returns nothing. Why does it return nothing, don't we need to know which filters are active in other parts of the program? Please discuss this in the forums.
change_filter() will repeatedly print the (filtered) sensor list (use the print_filter function) and ask the user to enter the room number for the sensor that we want to add to or remove from the filter list. The user can also enter x to exit. If the user enters an invalid sensor, the user gets an error message (see the sample run) but the loop continues. The function should be updating filter_list as the user adds or removes filters.
Finally, update the main menu so that it correctly calls change_filter().
Sort the Sensor List
Have your program run the recursive sort function on sensor_list before the while loop that handles the menu - we only need to sort once. We want our sort to be on the room number string.
Here's a sample output, assuming that all but filter 4204(sensor 2) is active:
4201: Foundations Lab [ACTIVE]
4204: CS Lab
4205: Tiled Room [ACTIVE]
4213: STEM Center [ACTIVE]
4218: Workshop Room [ACTIVE]
Out: Outside [ACTIVE]
filter_list indicates which sensors should show the "ACTIVE" tag above. If filter_list contained [0,1,3,4,5], you would get the result above because sensor 2(room 4204) is not in filter_list.
In a future Lab Assignment, our program will display summary data from all the sensors in the STEM Center. We want to be able to restrict this to one room, or a group of rooms.
Program Test (the User Interaction Loop)
In a while loop, print the (filtered) sensor list by calling print_filter().
Then ask the user to enter one of the sensors (room numbers, like 4201 or Out) to add to or remove from the filter list.
The user will enter the room number (not the sensor number or room name - though keep in mind that 'Out' is considered a room number) to toggle the filter.
This repeats until the user enters x to exit.
If the user enters an invalid sensor number, the user gets an error message (see the sample run) but the loop continues.
At the least, provide the same unit tests in your submission as are provided in the sample run below.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!