The code must be coded in Python. Please fulfill requirements mentioned in the q
ID: 3719820 • Letter: T
Question
The code must be coded in Python. Please fulfill requirements mentioned in the question for an upvote.
Q2) Course Information (30 Points) Write a program that creates a dictionary containing course numbers and room numbers of the class rooms where the courses meet. The dictionary should have the following key-value pairs Course Number Room Number MIS120 MIS15 MIS101 MIS150 MIS160 alue TAH1009 ALP224 AMD132 TAH1026 ARC1013 The program also includes a dictionary containing course numbers and the names of the instructors that teach each course. The dictionary should have the following key-value pairs: Course Number MIS120 MIS15 MIS101 MIS150 MIS160 Room Number (Value) Beverly Smith Casey Woods Lisa Burton Violet Jenkins Curtis Spring 2018 MIS 15 HOMEWORK 5 The program includes another dictionary containing course numbers and class timings for each course. Room Number (Value) 6:00pm 1:30pm 9:00am 12:00pm Course Number MIS120 MIS15 MIS101 MIS150 MIS160 The program should let the user enter a course number, and displays the course's room number instructor, and meeting time. If the course number is not in the dictionary, display a message Invalid Course Number" Write separate function for each dictionary. getCourseNumber, getInstructor, getMeetingTime.Explanation / Answer
################# Program dict.py ##########################
courseRoomDict = dict()
courseInstructorDict = dict()
courseTimeDict = dict()
courseRoomDict = {'MIS120':'TAH1009', 'MIS15':'ALP224','MIS101':'AMD132','MIS150':'TAH1026','MIS160':'ARC1013'}
courseInstructorDict = {'MIS120':'Beverly Smith', 'MIS15':'Casey Woods','MIS101':'Lisa Burton','MIS150':'Voilet Jenkins','MIS160':'Troy Curtis'}
courseTimeDict = {'MIS120':'6:00pm', 'MIS15':'1:30pm','MIS101':'9:00am','MIS150':'12:00pm','MIS160':'4:30pm'}
courseNum = None
def getCourseNumber():
courseNum = input("Enter a course Number (to fetch details) : ")
return str(courseNum)
def getRoom(courseNum):
if courseNum in courseRoomDict.keys():
return courseRoomDict[courseNum]
else:
return None
def getInstructor(courseNum):
if courseNum in courseInstructorDict.keys():
return courseInstructorDict[courseNum]
else:
return None
def getMeetingTime(courseNum):
if courseNum in courseTimeDict.keys():
return courseTimeDict[courseNum]
else:
return None
def main():
print " Course Room Dictionary:-"
for key in courseRoomDict.keys():
print key + " " + courseRoomDict[key]
print " Course Instructor Dictionary:-"
for key in courseInstructorDict.keys():
print key + " " + courseInstructorDict[key]
print " Course Time Dictionary:-"
for key in courseTimeDict.keys():
print key + " " + courseTimeDict[key]
print " "
courseNum = getCourseNumber()
print " "
room = getRoom(courseNum)
if room == None:
print "ERROR: Invalid Course number"
return
instructor = getInstructor(courseNum)
if instructor == None:
print "ERROR: No Instructor found for course Number " + courseNum
time = getMeetingTime(courseNum)
if time == None:
print "ERROR: No Meeting Time found for course Number " + courseNum
print "Course Number " + str(courseNum) + " Room " + str(room) + " Instructor " + str(instructor) + " Time " + str(time)
#//////////////////////// start code//////////////////////
if __name__ == "__main__":
main()
print " "
//////////////////////////////output//////////////
hax-vikashar-1$ python dict.py -----------1st RUN
Course Room Dictionary:-
MIS160 ARC1013
MIS120 TAH1009
MIS101 AMD132
MIS15 ALP224
MIS150 TAH1026
Course Instructor Dictionary:-
MIS160 Troy Curtis
MIS120 Beverly Smith
MIS101 Lisa Burton
MIS15 Casey Woods
MIS150 Voilet Jenkins
Course Time Dictionary:-
MIS160 4:30pm
MIS120 6:00pm
MIS101 9:00am
MIS15 1:30pm
MIS150 12:00pm
Enter a course Number (to fetch details) : "MIS150"
Course Number MIS150
Room TAH1026
Instructor Voilet Jenkins
Time 12:00pm
hax-vikashar-1$ python dict.py ---------2nd RUN
Course Room Dictionary:-
MIS160 ARC1013
MIS120 TAH1009
MIS101 AMD132
MIS15 ALP224
MIS150 TAH1026
Course Instructor Dictionary:-
MIS160 Troy Curtis
MIS120 Beverly Smith
MIS101 Lisa Burton
MIS15 Casey Woods
MIS150 Voilet Jenkins
Course Time Dictionary:-
MIS160 4:30pm
MIS120 6:00pm
MIS101 9:00am
MIS15 1:30pm
MIS150 12:00pm
Enter a course Number (to fetch details) : "MIS154"
ERROR: Invalid Course number