Question: 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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
