Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Q3: Course Scheduling - 35 pts In this question, you will practice File 1/0 with multiple input files. In particular, you are given three

python image text in transcribed
image text in transcribed
Q3: Course Scheduling - 35 pts In this question, you will practice File 1/0 with multiple input files. In particular, you are given three files related to the scheduling of classes at Ko University in Spring 2020 instructors.txt contains the names, IDs, and instructors of courses locations txt: contains the physical location (room) of each course times.txt: contains the timeslot (day, start time, end time) of each course The starter code for this question is given in CourseScheduling-py. Implement the empty functions in the starter code to solve the following parts. PART A: Write a function called read_schedules() that reads course schedules from the 3 given files and stores them in a dictionary of dictionaries, data =( "COMP110": {"Name" "Introduction to Programming with Matlab", "Instructor": "Emre Kutukoglu", "Location":"SC1103" "Days": TuTh" "Start Time": "8:30 "End Time":"9:45) "COMP125": {"Name": "Programming with Python", "Instructor: "Ayca Tuzmen". "Location": "ENG250" "Days": "TuTh". "Start Time": -13.00 "End Time": "14:15) } For the outer dictionary data, the key should be the course ID (e.g.: "COMP110 *COMP125", "ELEC204") and the value should be a dictionary. For the inner dictionary, the keys should be "Name", "Instructor", "location", "Days". "Start Time". "End Time', and the values should be the corresponding information for that course as shown above. The return value of read_schedules() should be the main dictionary data. Hint You should first read instructors.but when creating the outer dictionary data, and later populate the location and time details using locations.txt and times.bit. PART B: Some courses included in instructors.but are missing location assignments or time assignments, i.e. they are included in instructors.txt but not in locations.bit or times.txt. Write a function find_unscheduled(data) that Takes as input the main dictionary data constructed above Has two return values: First return value is the list of courses that have no location Example: [COMP306", "INDR460) Second return value is the list of courses that have no timeslot Example: [ELEC422". "MECH435...] . PART C: Write a function clean_schedule(data, courses_to_remove) such that: data is the main dictionary constructed in Part A courses_to_remove is the list of courses that should be removed from data o Example: [ELEC422", "MECH435", ...] Your function should return the resulting dictionary after the courses are removed from it Caution: This function must retum the resulting dictionary, do not just modify the dictionary in-place. PART D: Write a function find_instructor(data, courselD) such that: data is the main dictionary constructed in Part A courselD is a string containing the ID of one course Example: courselD = "COMP125" or courselD="MECH433" Your function should return the instructor who is teaching that course o If the given courseld does not exist in data, your function should retum the following string: "NA: PARTE: Write a function find_sub}_courses(data, subject) such that: data is the main dictionary constructed in Part A subject is the 4-letter subject area o Example: subject -"COMP" or subject = "ELEC" or subject = "MECH" Your function should retum the list of all courses from that subject area Example: ["COMP110", "COMP125", "COMP131". ..., "COMP437") PART F: Write a function build_schedule(data, courses) such that: data is the main dictionary constructed in Part A courses is a list containing course IDs that a student is interested in taking Example: courses = ["COMP125". "MECH301", "COMP 305", "ELEC301) File output: Your function should create and write to a file called "student but the schedule of this student. For the above example, contents of student.txt will be: COMP125 ENGZ50, TuTh, 13:00, 14:15 MECH301,SOSZ27 MoWe 10:00 11:15 COMP305,SOSB07 MoWe,8:30,9:45 ELEC301,SNA 159,Mowe,13:00, 14:15 If the given courses have a time conflict, i.e., they overlap. then the student cannot take the given list of courses simultaneously. In this case, your program should write only the following to student.txt (course IDs, locations, times should not be written): ** Time conflict

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions