Devin Dahlberg

Python: Assignment Nine

#Problem 1
#Write a program that creates a dictionary containing course numbers and the room numbers of the rooms where the courses meet.
#The program should also create a dictionary containing course numbers and the names of the instructors that teach each course.
#The program should also create a dictionary containing course numbers and the meeting times of each course.
#The program should let the user enter a course number, then it should display the course’s room number, instructor, and meeting time.

course = ['CS101', 'CS102', 'CS103', 'NT110', 'CM241']

room = {'CS101' : '3004', 'CS102' : '4501', 'CS103' : '6755', 'NT110' : '1244', 'CM241' : '1411'}

instructor = {'CS101' : 'Haynes', 'CS102' : 'Alvarado', 'CS103' : 'Rich', 'NT110' : 'Burke', 'CM241' : 'Lee'}

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.'}

user_input = input('Please enter a course number: ')

if user_input == 'CS101':
    print('Room Number:',room['CS101'])
    print('Instructor:',instructor['CS101'])
    print('Time:',time['CS101'])

if user_input == 'CS102':
    print('Room Number:',room['CS102'])
    print('Instructor:',instructor['CS102'])
    print('Time:',time['CS102'])

if user_input == 'CS103':
    print('Room Number:',room['CS103'])
    print('Instructor:',instructor['CS103'])
    print('Time:',time['CS103'])

if user_input == 'NT110':
    print('Room Number:',room['NT110'])
    print('Instructor:',instructor['NT110'])
    print('Time:',time['NT110'])

if user_input == 'CM241':
    print('Room Number:',room['CM241'])
    print('Instructor:',instructor['CM241'])
    print('Time:',time['CM241'])

if user_input not in course:
    print('Course number not found. Exiting...')

HW9P1 v2

#Unique words in book.
#Write a program that opens a specified text file then displays a list of all the unique words found in the file.
#Use a set.
#The text file to test against is attached

myfile = open('text2.txt', 'r')

line = myfile.readline()

words = line.split(' ')

myset = set(words)

print(f"The unique words found in the file are: {myset}")

HW9P2