Write Python program that creates a dictionary containing course numbers and the
ID: 3561610 • Letter: W
Question
Write Python program that creates a dictionary containing course numbers and the room numbers where the courses meet. The program should also have names of instructors and meeting times.
Here is what I have, but I know something is off. Please come up with the solution so it will work in python 3.4.1
course_time={}
course_time['CS101']='8:00 a.m.'
course_time['CS102']='9:00 a.m.'
course_time['CS103']='10:00 a.m.'
course_time['NT110']='11:00 a.m.'
course_time['CM241']='1:00 p.m.'
course_ins={}
course_ins['CS101']='Haynes'
course_ins['CS102']='Alvarado'
course_ins['CS103']='Rich'
course_ins['NT110']='Burke'
course_ins['CM241']='Lee'
course_room={}
course_room['CS101']='3004'
course_room['CS102']='4501'
course_room['CS103']='6755'
course_room['NT110']='1244'
course_room['CM241']='1411'
n=raw_input("Enter course number:")
n=n.upper()
print("Room number for Course %s is %s" % (n, course_room[n]))
print("Instructor for Course %s is %s" % (n, course_ins[n]))
print("Meeting Time for Course %s is %s" % (n, course_time[n]))
Explanation / Answer
Sample output:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
code to copy:
#!/usr/local/bin/python2.7
course_time={};
course_time['CS101']='8:00 a.m.';
course_time['CS102']='9:00 a.m.';
course_time['CS103']='10:00 a.m.';
course_time['NT110']='11:00 a.m.';
course_time['CM241']='1:00 p.m.';
#python3 syntax
course2_time = {'CS101': '8:00 a.m.', 'CS102': '9:00 a.m.','CS103':'10:00 a.m.','NT110':'11:00 a.m.','CM241':'1:00 p.m.'};
course_ins={};
course_ins['CS101']='Haynes';
course_ins['CS102']='Alvarado';
course_ins['CS103']='Rich';
course_ins['NT110']='Burke';
course_ins['CM241']='Lee';
#python3 syntax
course2_ins = {'CS101': 'Haynes', 'CS102': 'Alvarado','CS103':'Rich','NT110':'Burke','CM241':'Lee'};
course_room={};
course_room['CS101']='3004';
course_room['CS102']='4501';
course_room['CS103']='6755';
course_room['NT110']='1244';
course_room['CM241']='1411';
#python3 syntax
course2_room = {'CS101': '3004', 'CS102': '4501','CS103':'6755','NT110':'1244','CM241':'1411'};
n=raw_input("Enter course number:");
n=n.upper();
print("Room number for Course %s is %s" % (n, course_room[n]));
print("Room number for Course %s is %s" % (n, course2_room[n]));
print("Instructor for Course %s is %s" % (n, course_ins[n]));
print("Instructor for Course %s is %s" % (n, course2_ins[n]));
print("Meeting Time for Course %s is %s" % (n, course_time[n]));
print("Meeting Time for Course %s is %s" % (n, course2_time[n]));
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.