Focus on dictionary methods, use of functions, and good programming style For this assignment, you will create a glossary (dictionary) of technical terms and definitions. It will be set up as a Python dictionary structure. The file glossary_starter.py is a complete starter framework for the assignment. It includes some initial values for the dictionary. It is long because most of the code has already been written for you. Your task is to complete the five individual functions for adding and deleting terms, looking up terms, listing them, and printing out both the terms and definitions. These functions are all short, just a couple of lines, and use basic dictionary methods and techniques. Here is some sample output(Attached) And here is the glossary_starter.py: """ Program framework for module 9 graded program      Creating a dictionary of technical terms and basic definitions         key - the word to define         value - the definition of the word     Note: This isn't a usable application, as new data added is just temporary. """ tech_terms = { "dict": "stores a key/value pair",                "list": "stores a value at each index",                "map": "see 'dict'",                "set": "stores unordered unique elements" } def main():     """ Keeps presenting the menu to the user till user asks to quit """     # Present main menu      choice = menu()     # While user hasn't asked to quit     while choice != "6":         try:             # Run the code depending on user's choice             choice = int(choice)             run(choice)         except:             # User didn't enter a number             print("Invalid input, please enter a valid number (1-5)")         # Get next choice from user         choice = menu() def menu():     """ Print a simple menu to the user """     print("Systems Dictionary")     print("1) Add a term")     print("2) List terms")     print("3) Get a definition")     print("4) Delete a term")     print("5) Print out dictionary")     print("6) Quit")     return input("Enter your choice: ") def run(choice):     """ Runs one of the actions that the user choose.  Valid choices are:         1-5 each of which corresponds to a specific action """     if choice == 1:         add()     elif choice == 2:         list()     elif choice == 3:         lookup()     elif choice == 4:         delete()     elif choice == 5:         show_it()     else:         print("Invalid input, please enter a valid number (1-6)") def add():     """ Adds a term to the dictionary """     # Get a new term and definition from the user     # Add the term/definition from the user to the dictionary def list():     """ List all the terms (no definitions) that are in the dictionary.         Once all terms have been listed, this function will also print         the total number of entries in the dictionary """     # TODO: Add your code here def lookup():     """ Lookup a term and print the definition """     # Get a term to lookup in the dictionary from the user     # Print the definition for the term     # TODO: Add your code here def delete():     """ Deletes a term from the dictionary """     # Get a term to delete from the user     # Delete the term specified by the user from the dictionary     # TODO: Add your code here def show_it():     """ Displays the full dictionary """     # Display the terms and definitions nicely formatted     # TODO: Add your code here # Run the program main()

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Focus on dictionary methods, use of functions, and good programming style For this assignment, you will create a glossary (dictionary) of technical terms and definitions. It will be set up as a Python dictionary structure. The file glossary_starter.py is a complete starter framework for the assignment. It includes some initial values for the dictionary. It is long because most of the code has already been written for you. Your task is to complete the five individual functions for adding and deleting terms, looking up terms, listing them, and printing out both the terms and definitions. These functions are all short, just a couple of lines, and use basic dictionary methods and techniques. Here is some sample output(Attached)

And here is the glossary_starter.py:

""" Program framework for module 9 graded program 
    Creating a dictionary of technical terms and basic definitions
        key - the word to define
        value - the definition of the word
    Note: This isn't a usable application, as new data added is just temporary.
"""

tech_terms = { "dict": "stores a key/value pair",
               "list": "stores a value at each index",
               "map": "see 'dict'",
               "set": "stores unordered unique elements" }

def main():
    """ Keeps presenting the menu to the user till user asks to quit """
    # Present main menu 
    choice = menu()

    # While user hasn't asked to quit
    while choice != "6":
        try:
            # Run the code depending on user's choice
            choice = int(choice)
            run(choice)
        except:
            # User didn't enter a number
            print("Invalid input, please enter a valid number (1-5)")

        # Get next choice from user
        choice = menu()

def menu():
    """ Print a simple menu to the user """
    print("Systems Dictionary")
    print("1) Add a term")
    print("2) List terms")
    print("3) Get a definition")
    print("4) Delete a term")
    print("5) Print out dictionary")
    print("6) Quit")
    return input("Enter your choice: ")


def run(choice):
    """ Runs one of the actions that the user choose.  Valid choices are:
        1-5 each of which corresponds to a specific action """
    if choice == 1:
        add()
    elif choice == 2:
        list()
    elif choice == 3:
        lookup()
    elif choice == 4:
        delete()
    elif choice == 5:
        show_it()
    else:
        print("Invalid input, please enter a valid number (1-6)")


def add():
    """ Adds a term to the dictionary """
    # Get a new term and definition from the user


    # Add the term/definition from the user to the dictionary


def list():
    """ List all the terms (no definitions) that are in the dictionary.
        Once all terms have been listed, this function will also print
        the total number of entries in the dictionary """
    # TODO: Add your code here


def lookup():
    """ Lookup a term and print the definition """
    # Get a term to lookup in the dictionary from the user


    # Print the definition for the term
    # TODO: Add your code here


def delete():
    """ Deletes a term from the dictionary """
    # Get a term to delete from the user


    # Delete the term specified by the user from the dictionary
    # TODO: Add your code here

def show_it():
    """ Displays the full dictionary """

    # Display the terms and definitions nicely formatted
    # TODO: Add your code here

# Run the program
main()    

1) Delete a term
5) Print out dictionary
5) Quit
Enter your choice: 4
What term do you want to delete? set
Deleted: data structure that stores
Glossary System
1) Add a term
2) List terms
3) Get a definition
1) Delete a term
5) Print out dictionary.
5) Quit
Glossary System
1) Add a term
Choose 4 again & enter a
Enter your choice: 4
what term do you want to delete? seterm, but it is not there
Deleted: No such term
2) List terms
3) Get a definition
1) Delete a term
5) Print out dictionary
5) Quit
Enter your choice: 5
Technical terms in glossary
argument
dictionary
hashmap
list
string
Glossary System
1) Add a term
2) List terms
3) Get a definition
Choose 4 & enter a term
unordered unique elements
Print out the entire glossary
data that is passed to a function
data structure that stores key/value pair
see 'dictionary'
data structure that stores values ordered by integer indexes
A basic type in Python that stores text.
1) Delete a term
5) Print out dictionary
5) Quit
Enter your choice: 6
Notice that for 2 and 5, the terms are listed in alphabetical order. Also, lookup and delete should not be case sensitive.
Quit
Transcribed Image Text:1) Delete a term 5) Print out dictionary 5) Quit Enter your choice: 4 What term do you want to delete? set Deleted: data structure that stores Glossary System 1) Add a term 2) List terms 3) Get a definition 1) Delete a term 5) Print out dictionary. 5) Quit Glossary System 1) Add a term Choose 4 again & enter a Enter your choice: 4 what term do you want to delete? seterm, but it is not there Deleted: No such term 2) List terms 3) Get a definition 1) Delete a term 5) Print out dictionary 5) Quit Enter your choice: 5 Technical terms in glossary argument dictionary hashmap list string Glossary System 1) Add a term 2) List terms 3) Get a definition Choose 4 & enter a term unordered unique elements Print out the entire glossary data that is passed to a function data structure that stores key/value pair see 'dictionary' data structure that stores values ordered by integer indexes A basic type in Python that stores text. 1) Delete a term 5) Print out dictionary 5) Quit Enter your choice: 6 Notice that for 2 and 5, the terms are listed in alphabetical order. Also, lookup and delete should not be case sensitive. Quit
Glossary System
1) Add a term
2) List terms
3) Get a definition
4) Delete a term
5) Print out dictionary
6) Quit
Enter your choice: 2
argument
dictionary
hashmap
list
set
5 terms.
Glossary System
1) Add a term
Print the menu
2) List terms
3) Get a definition
User chooses 2 - list the terms
Menu again
6) Quit
User chooses 1 - add a term
Enter your choice: 1
What term do you want to add? String
User enters term and definition
What is the definition for 'string'? A basic type in Python that stores text.
Glossary System
1) Add a term
Menu again
User chooses 3 - look up a term
5) Quit
Enter your choice: 3
What term do you want to lookup? STRING
definition of "string" A basic type in Python that stores text.
Then enters term to look up
Transcribed Image Text:Glossary System 1) Add a term 2) List terms 3) Get a definition 4) Delete a term 5) Print out dictionary 6) Quit Enter your choice: 2 argument dictionary hashmap list set 5 terms. Glossary System 1) Add a term Print the menu 2) List terms 3) Get a definition User chooses 2 - list the terms Menu again 6) Quit User chooses 1 - add a term Enter your choice: 1 What term do you want to add? String User enters term and definition What is the definition for 'string'? A basic type in Python that stores text. Glossary System 1) Add a term Menu again User chooses 3 - look up a term 5) Quit Enter your choice: 3 What term do you want to lookup? STRING definition of "string" A basic type in Python that stores text. Then enters term to look up
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 8 images

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education