Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Python function school_courses which consumes data, a nonempty string containing the name of the file containing information about this term's students and the
Write a Python function school_courses which consumes data, a nonempty string containing the name of the file containing information about this term's students and the courses they are enrolled in. The function returns a new dictionary: The keys correspond to the names of the courses (all in upper case). You may assume that courses' names do not include space The corresponding value for a course is a list of all students who are enrolled in this course This list must be sorted into alphabetical order for the names of the students, based on Python's sort method The input file will have the name of a student in a line, followed by a list of courses the student is enrolled in, then a blank line, and then information about another student. For example, the provided file s18.txt follows this format. You may assume the following: .There will be information about at least one student in the consumed file. .There will be at least one course listed for each student. Two course names are the same regardless of upper and lower case differences, for example CS116, Cs116, cS116, cs116, all are considered to be the same course Calling school_courses ("s18.txt") returns {"CS115': ['Alice Dean', 'Dave Brown ', 'Mary Sue '], 'MATH 135': ['Alice Dean', Dave Brown', 'CHEM100': ['Alice Dean', 'Dave Brown', 'Mary Sue','MATH200' ['Alice Dean', 'Mary Sue')
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