Python Question
Understand the Application
This assignment is a little more challenging. Be sure to read the spec several times before you start coding, and again just before you submit your assignment.
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.
Here’s a sample run of the complete program:
STEM Center Temperature Project
Cleveland Brown
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 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 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 to toggle (e.g. 4201) or x to end Out
4201: Foundations Lab
4204: CS Lab [ACTIVE]
4205: Tiled Room
4213: STEM Center [ACTIVE]
4218: Workshop Room [ACTIVE]
Out: Outside
Type the sensor to toggle (e.g. 4201) or x to end Out
4201: Foundations Lab
4204: CS Lab [ACTIVE]
4205: Tiled Room
4213: STEM Center [ACTIVE]
4218: Workshop Room [ACTIVE]
Out: Outside [ACTIVE]
Type the sensor to toggle (e.g. 4201) or x to end 4201
4201: Foundations Lab [Active]
4204: CS Lab [ACTIVE]
4205: Tiled Room
4213: STEM Center [ACTIVE]
4218: Workshop Room [ACTIVE]
Out: Outside
Type the sensor to toggle (e.g. 4201) or x to end 4000
Invalid Sensor
4201: Foundations Lab
4204: CS Lab [ACTIVE]
4205: Tiled Room
4213: STEM Center [ACTIVE]
4218: Workshop Room [ACTIVE]
Out: Outside
Type the sensor 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?
As a reminder, here is wjhat the module docstring for assigment should look like.
Author: Mike Murphy
CWID: 20123456
Date: 5/28/2023
Enhancements by Assignment
Assignment 7: This assignment introduces two methods (in detail)
print_filter() – prints a list of sensors that are active and inactive
change_filter() – allows a user to activate a sensor or deactivate it
The change_filter() is initiated through the menu prompt #3 choice.
The change_filter() method will print the filter list showing active or
inactive states, and it will allow the user to turn a sensor on or off.
Assignment 6: Bubble sort a sensor list but using recursion. Use a test case
as provided (similar to assignment 5, but with reference to the
sensor list information from assignment 4).
Assignment 5: A separate recursion assignment (as another project; see assignment 5)
Assignment 4: Apply the use of container objects (lists, tuples, sets, and dictionaries)
to create and populate some container objects. A container object is needed
to store information about the sensors that are included in the STEM Center
dataset. Sensors are thermometers which are placed in various rooms in the
building and outside the building. Two different container objects will be
used to store data and a third container object to keep track of which
sensors.
Assignment 3: Add a menu that provides an interface where a user will use
to interact with the program. This new code will employ loops
and conditionals. This is building on the previous assignment
but will use a new main() to test the menu.
Assignment 2: Add code to prompt the user for a temperature in Celsius
and then converts that temperature to a specified different temperature
unit.
Assignment 1: Implement the print_header() that prints the opening
lines for the STEM Center Project
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
