Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def main ( ) : Builds the required data structures for the program. # Dictionary containing room number as
def main: Builds the required data structures for the program. # Dictionary containing room number as key sensors : STEM Center", : Foundations Lab", : Computer Science Lab", : Workshop : Tiled Room", "Out": Outside # Create sensor list sensorlist roomnum, roomdesc, sensornum for roomnum, roomdesc, sensornum in sensorsitems # Create filter list filterlist sensornum for sensornum in sensorsitems # Example: Searching room searchroom if searchroom in sensors: printRoom found:", sensorssearchroom else: printRoom can't be found." # Print the created lists printSensors List:", sensorlist printFilters List:", filterlist if namemain: main Assignment: Add the function recursivesort which has as its parameters, listtosort a list of tuples like the one you just made and key. key should have a default value of zero, and refers to whether the list should be sorted by the first or second value in the tuple. Of course, recursivesort should call itself as part of the process. When exchanging the items in the list use tuple unpacking The sorted part of the list will be growing from the end of the list the greatest value Each time you call recursivesort, you should be calling with a smaller list. You can use slicing for this.
def main:
Builds the required data structures for the program.
# Dictionary containing room number as key
sensors
: STEM Center",
: Foundations Lab",
: Computer Science Lab",
: Workshop
: Tiled Room",
"Out": Outside
# Create sensor list
sensorlist roomnum, roomdesc, sensornum for roomnum, roomdesc, sensornum in sensorsitems
# Create filter list
filterlist sensornum for sensornum in sensorsitems
# Example: Searching room
searchroom
if searchroom in sensors:
printRoom found:", sensorssearchroom
else:
printRoom can't be found."
# Print the created lists
printSensors List:", sensorlist
printFilters List:", filterlist
if namemain:
main Assignment: Add the function recursivesort which has as its parameters, listtosort a list of tuples like the one you just made and key.
key should have a default value of zero, and refers to whether the list should be sorted by the first or second value in the tuple.
Of course, recursivesort should call itself as part of the process.
When exchanging the items in the list use tuple unpacking
The sorted part of the list will be growing from the end of the list the greatest value
Each time you call recursivesort, you should be calling with a smaller list.
You can use slicing for this.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started