Question: Understand the Application in Python NOTE: I have made some changes to the definition of the change_filter function since assignment three. Please update your function
Understand the Application in Python
NOTE: I have made some changes to the definition of the change_filter function since assignment three. Please update your function definition and function call as described here.
All right folks, the rubber hits the road here. This assignment should be a little challenging. Be sure you read the spec several times before you start coding, and again before you submit your assignment.
First of all, make sure your sensors dictionary, your routine to load the sensor list and filter list, and your recursive_sort() function are all brought in to your project. The recursive_sort() function definition should be at the top of your program with your other function definitions. The other items should come just before the while loop that runs the menu.
Have your program run the sort routine on the 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.
Next we will implement menu item number 3 from the menu.
Eventually 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..
Now we need a function that will print the list of filters, and note which ones are currently active. We will call 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.
Here's some 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]
This is a good time to do some testing to make sure you have this much working. No sense going on to the next step if this one isn't done!
Next we need to create a function called change_filter(). 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 in the forums.
change_filter() will print the (filtered) sensor list by calling print_filter(), and then and ask the user to enter one of the sensors to add to or remove from the filter list. The user will enter the room number (not the sensor number or room name) to toggle the filter. This repeats until the user enters 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().
Here's a sample run of the complete program:
STEM Center Temperature Project Eric Reed Main Menu --------- 1 - Process a new data file 2 - Choose units 3 - Edit room filter 4 - Show summary statistics 5 - Show temperature by date and time 6 - Show histogram of temperatures 7 - Quit What is your choice? 3 4201: Foundations Lab [ACTIVE] 4204: CS Lab [ACTIVE] 4205: Tiled Room [ACTIVE] 4213: STEM Center [ACTIVE] 4218: Workshop Room [ACTIVE] Out: Outside [ACTIVE] Type the sensor number to toggle (e.g.4201) or x to end 4201 4201: Foundations Lab 4204: CS Lab [ACTIVE] 4205: Tiled Room [ACTIVE] 4213: STEM Center [ACTIVE] 4218: Workshop Room [ACTIVE] Out: Outside [ACTIVE] Type the sensor number to toggle (e.g.4201) or x to end 4205 4201: Foundations Lab 4204: CS Lab [ACTIVE] 4205: Tiled Room 4213: STEM Center [ACTIVE] 4218: Workshop Room [ACTIVE] Out: Outside [ACTIVE] Type the sensor number to toggle (e.g.4201) or x to end 4205 4201: Foundations Lab 4204: CS Lab [ACTIVE] 4205: Tiled Room [ACTIVE] 4213: STEM Center [ACTIVE] 4218: Workshop Room [ACTIVE] Out: Outside [ACTIVE] Type the sensor number to toggle (e.g.4201) or x to end 400 Invalid Sensor 4201: Foundations Lab 4204: CS Lab [ACTIVE] 4205: Tiled Room [ACTIVE] 4213: STEM Center [ACTIVE] 4218: Workshop Room [ACTIVE] Out: Outside [ACTIVE] Type the sensor number to toggle (e.g.4201) or x to end x Main Menu --------- 1 - Process a new data file 2 - Choose units 3 - Edit room filter 4 - Show summary statistics 5 - Show temperature by date and time 6 - Show histogram of temperatures 7 - Quit What is your choice?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
