Still in the groups from last class (online students do remainder of assignment), using the dictionary application you created, add two new menu items: ➤ Save the dictionary - write a function to pickle the dictionary to a file ➤ Retrieve the dictionary - write a function to retrieve the pickled dictionary that was saved earlier ➤ Put both functions in a separate module that is imported by your main program Turn in your programs/modules to the practice assignment link in course content.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

using Python. Practice 9-2 continue to practice 9-1 and I will write the birthday dictionary because I couldn't take a pic of it

birthday dictionary code

# This program uses a dictionary to keep friends'
# names and birthdays.

# Global constants for menu choices
LOOK_UP = 1
ADD = 2
CHANGE = 3
DELETE = 4
QUIT = 5

# main function
def main():
    # Create an empty dictionary.
    birthdays = {}

    # Initialize a variable for the user's choice.
    choice = 0

    while choice != QUIT:
        # Get the user's menu choice.
        choice = get_menu_choice()

        # Process the choice.
        if choice == LOOK_UP:
            look_up(birthdays)
        elif choice == ADD:
            add(birthdays)
        elif choice == CHANGE:
            change(birthdays)
        elif choice == DELETE:
            delete(birthdays)

# The get_menu_choice function displays the menu
# and gets a validated choice from the user.
def get_menu_choice():
    print()
    print('Friends and Their Birthdays')
    print('---------------------------')
    print('1. Look up a birthday')
    print('2. Add a new birthday')
    print('3. Change a birthday')
    print('4. Delete a birthday')
    print('5. Quit the program')
    print()

    # Get the user's choice.
    choice = int(input('Enter your choice: '))

    # Validate the choice.
    while choice < LOOK_UP or choice > QUIT:
        choice = int(input('Enter a valid choice: '))

    # return the user's choice.
    return choice

# The look_up function looks up a name in the
# birthdays dictionary.
def look_up(birthdays):
    # Get a name to look up.
    name = input('Enter a name: ')

    # Look it up in the dictionary.
    print(birthdays.get(name, 'Not found.'))

# The add function adds a new entry into the
# birthdays dictionary.
def add(birthdays):
    # Get a name and birthday.
    name = input('Enter a name: ')
    bday = input('Enter a birthday: ')

    # If the name does not exist, add it.
    if name not in birthdays:
        birthdays[name] = bday
    else:
        print('That entry already exists.')

# The change function changes an existing
# entry in the birthdays dictionary.
def change(birthdays):
    # Get a name to look up.
    name = input('Enter a name: ')

    if name in birthdays:
        # Get a new birthday.
        bday = input('Enter the new birthday: ')

        # Update the entry.
        birthdays[name] = bday
    else:
        print('That name is not found.')

# The delete function deletes an entry from the
# birthdays dictionary.
def delete(birthdays):
    # Get a name to look up.
    name = input('Enter a name: ')

    # If the name is found, delete the entry.
    if name in birthdays:
        del birthdays[name]
    else:
        print('That name is not found.')

# Call the main function.
main()

    

Practice Assignment Ch. 9-2
Still in the groups from last class (online students do remainder of assignment), using
the dictionary application you created, add two new menu items:
➤ Save the dictionary - write a function to pickle the dictionary to a file
> Retrieve the dictionary - write a function to retrieve the pickled
dictionary that was saved earlier
➤ Put both functions in a separate module that is imported by your main
program
Turn in your programs/modules to the practice assignment link in
course content.
Transcribed Image Text:Practice Assignment Ch. 9-2 Still in the groups from last class (online students do remainder of assignment), using the dictionary application you created, add two new menu items: ➤ Save the dictionary - write a function to pickle the dictionary to a file > Retrieve the dictionary - write a function to retrieve the pickled dictionary that was saved earlier ➤ Put both functions in a separate module that is imported by your main program Turn in your programs/modules to the practice assignment link in course content.
Practice Assignment Ch. 9-1
1.
2.
3.
4.
5.
➤
Classroom Sections: Group assignment - break into groups of 3 or 4.
Online students: do on your own.
Using the example of the birthday dictionary in Chapter 9, create a dictionary application, subject of your choosing
(appropriate content)
In addition to the menu choices provided to the user in the example, add menu items to display the entire
dictionary.
Each person will create a separate module for their function(s) with the main program importing all the modules.
Person 1 - main program/menu display, coordinates other programs
Person 2 - Look up and display functions
Person 3 - Add function
Person 4 - Change, and Delete functions
Turn in your programs/modules to the practice assignment link in course content.
Transcribed Image Text:Practice Assignment Ch. 9-1 1. 2. 3. 4. 5. ➤ Classroom Sections: Group assignment - break into groups of 3 or 4. Online students: do on your own. Using the example of the birthday dictionary in Chapter 9, create a dictionary application, subject of your choosing (appropriate content) In addition to the menu choices provided to the user in the example, add menu items to display the entire dictionary. Each person will create a separate module for their function(s) with the main program importing all the modules. Person 1 - main program/menu display, coordinates other programs Person 2 - Look up and display functions Person 3 - Add function Person 4 - Change, and Delete functions Turn in your programs/modules to the practice assignment link in course content.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Can you give me an answer for each question for a unit practice 9-1 separate from practice 9-2

Solution
Bartleby Expert
SEE SOLUTION
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY