Question

Using Python. Please help!

The output should looks like below. Please follow the emphasis.

Write a modular program that creates a dictionary containing course numbers and the room numbers of the rooms where the cours

• • code should work for both cs101 or CS101 course entries course name should display in all caps or lower cases regardl

I think it just prompt user to input course name.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for the question, here is the complete implementation of the code. Let me know if anything else needs to be incorporated

the program is modularised and written with meaningful name so that you can follow.

==========================================================================================

def getChoice():
    print('[1] View Course Details')
    print('[2] Add Class')
    print('[3] Remove Class')
    print('[4] View Schedule')
    print('[5] Quit')
    choice=input('Enter your choice: ')
    return choice


def viewCourse(room_dict, instructor_dict, time_dict):
    print('{0:<10}{1:>20}{2:>20}{3:>20}'.format('Course Number','Instructor','Room Number','Meeting Time'))
    for course in room_dict.keys():
        print('{0:<10}{1:>20}{2:>20}{3:>20}'.format(course,instructor_dict.get(course),room_dict.get(course),time_dict.get(course)))


def addClass(room_dict, instructor_dict, time_dict):
    course=input('Enter course number: ').upper()
    if course in room_dict.keys():
        print('Course by that number already exists.')
        return
   
room_number=input('Enter room number: ')
    instructor_name=input('Enter instructor name: ')
    meeting_time=input('Enter meeting time: ')
    room_dict[course]=room_number
    instructor_dict[course]=instructor_name
    time_dict[course]=meeting_time
    print('Data saved successfully.')


def removeClass(room_dict, instructor_dict, time_dict):
    course=input('Enter course number: ').upper()
    if course in room_dict.keys():
        room_dict.pop(course)
        instructor_dict.pop(course)
        time_dict.pop(course)
        print('Course deleted successfully.')
    else:
        print('Course by that number does not exists.')


def viewSchedule(room_dict, instructor_dict, time_dict):
    course=input('Enter course number: ').upper()
    if course in room_dict.keys():
        print('{0:<10}{1:>20}{2:>20}{3:>20}'.format('Course Number','Instructor','Room Number','Meeting Time'))
        print('{0:<10}{1:>20}{2:>20}{3:>20}'.format(course,instructor_dict.get(course),room_dict.get(course),time_dict.get(course)))




def main():
    room_dict={}
    instructor_dict={}
    time_dict={}

    while True:
        choice=getChoice()
        if choice=='1':viewCourse(room_dict,instructor_dict,time_dict)
        elif choice=='2':addClass(room_dict,instructor_dict,time_dict)
        elif choice=='3':removeClass(room_dict,instructor_dict,time_dict)
        elif choice=='4':viewSchedule(room_dict,instructor_dict,time_dict)
        elif choice=='5':break
        else
:print('Invalid choice.')

main()

def getChoice(): print([1] View Course Details) print( [2] Add class) print([3] Remove class) print([4] View Schedule)

def main(): room_dict={} instructor_dict={} time_dict={} while True: choice=getChoice() if choice==1:viewCourse (room_dict,

Add a comment
Know the answer?
Add Answer to:
Using Python. Please help! The output should looks like below. Please follow the emphasis. I think...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a program...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a program that creates a dictionary named rooms containing course numbers and the room numbers of the rooms where the courses meet. The dictionary should have the following key-value pairs: Course Number (Key) Room Number (Value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create a dictionary named instructors containing course numbers and the names of the instructors that teach...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a program...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a program that creates a dictionary named rooms containing course numbers and the room numbers of the rooms where the courses meet. The dictionary should have the following key-value pairs: Course Number (Key) Room Number (Value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create a dictionary named instructors containing course numbers and the names of the instructors that teach...

  • IN python, Write a program that creates a dictionary containing course numbers and the room numbers...

    IN python, Write a program that creates a dictionary containing course numbers and the room numbers where the courses meet. The dictionary should contain the following key:value pairs. Course Number (key) Room Number (value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create 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 (key) Instructor (value) CS101 Haynes CS102...

  • Phyton prog COMPLETE. Problem 1: Write a program that creates a directory containing course numbers and...

    Phyton prog COMPLETE. Problem 1: Write a program that creates a directory containing course numbers and the room numbers of the rooms where the courses meet. The dictionary should have the following key-value pairs: Course Number (key) Room Number (value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create 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...

  • Python 3.7 Coding assignment This Program should first tell users that this is a word analysis...

    Python 3.7 Coding assignment This Program should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file....

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • Pythong Program 4 should first tell users that this is a word analysis software. For any...

    Pythong Program 4 should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file. Using try/except for...

  • I need a C++ program like this please! and please follow all instructions! Thanks so much!...

    I need a C++ program like this please! and please follow all instructions! Thanks so much! A menu-driven program with 3 choices: Names Rearranger, Number Validator, or Exit Menu Option 1: Name Rearranger: 1. Input ONE STRING from the user containing first name, middle name, and last name. ie, "John Allen Smith". USE THE GETLINE function. (Not cin) 2. Loop through the string and validate for a-z or A-Z or . If the name has any other characters, then ask...

  • Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives...

    Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he or she is finished providing inputs. After the user presses the enter key, the program should print the sum of the numbers and their average. Q2. The credit plan at TidBit Computer Store specifies a 10% down payment and an annual interest rate of...

  • python Topics covered: Using variables e Arithmetic operators Printing output Manipulating string objects . Generating random...

    python Topics covered: Using variables e Arithmetic operators Printing output Manipulating string objects . Generating random numbers . Getting user input NOTE: Each of your files must include a docstring at the top of the file containing your name, username, ID number and a description of the program. When solving these questions you must only use content covered in lectures 1 to 6 Submit the files containing your exercises using the Assignment Dropbox https:/adb auckland.ac.nz/Homel QUESTION 1 (3 MARKS) A...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT