Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON HOW WOULD I COMPLETE THE FOLLOWING: Goals At the completion of this assignment, you should: have gained additional experience working with lists have

IN PYTHON HOW WOULD I COMPLETE THE FOLLOWING:

Goals

At the completion of this assignment, you should:

  • have gained additional experience working with lists
  • have gained additional experience working with input, strip() function and while loops
  • have gained additional experience working with conditionals, logical and Boolean operators, and break
  • have gained additional experience using functions
  • have gained experience using string isdigit() function
  • have gained additional experience creating more complex applications

Getting Started

For this assignment you will create a simple list manager program. Your list manager program will support the following use cases:

  • Add data to a list
  • Delete individual list items
  • Clear the entire list
  • Output available commands

The assignment contains the required functions, and a general outline to follow to implement the list manager program. As usual you are encouraged to follow the incremental development steps, including incremental testing.

Assignment

Part I: Required Functions

Create a file called cis122-assign07-list-manager.py for your list manager program.

Below is a list of required functions, where t is a list parameter. You should create all of these functions in your code file with a single statement pass (see the Python online documentation for pass (Links to an external site.), course text, or course lecture notes, if you forgot the purpose of pass).

  1. cmd_help()
  2. cmd_add(t)
  3. cmd_delete(t)
  4. cmd_list(t)
  5. cmd_clear(t)
  6. get_max_list_item_size(t)

You will also need to use your padding functions from Assignment 6. Copy all three functions into your code file.

  • pad_string()
  • pad_left()
  • pad_right()

Part II: List variable

You will require a list variable to hold your list items. The list item should be declared outside of any function, and initially be empty.

Part III: Primary Input Loop

You will require a primary input loop to prompt for list commands. The loop must only handle the commands, and then call the appropriate function to handle the command. You must use the strip() function to remove leading and trailing white space. If the Enter key is pressed with no input, exit the program.

The prompt must be: "Enter a command (? for help): ".

Part IV: Help Command

Your list manager must display help.

  1. If the ? is entered as a command, display a list of commands, and a command description.
  2. The commands must be contained within a list.
  3. The command descriptions must be contained within a separate list.
  4. These two lists must contain the same number of items.
  5. Use the get_max_list_item_size() function to find the maximum length of all of the commands.
  6. Use a for loop to iterate through the loops to display the help listing.
  7. Use the pad_right() function and the maximum command length to format the command, with a space between the command and the command description of five (5) spaces.
  8. Add "Empty to exit" as a final help tip.

See the sample output below.

image text in transcribed

Part V: Add Command

Your list manager program must support adding data to the list.

  1. The add command will prompt the user for data to add until the Enter key is pressed with no input.
  2. After each data is entered, display a notification that data was added, and a count of the total number of list items.

See the sample output below.

image text in transcribed

Part VI: List Command

The list command will display the total number of items in the list, and each item in the list.

See the image above in Part V and the add command for sample output.

Part VII: Clear Command

The clear command will clear (delete) all items in the list, and specify how many items were removed and that the list is now empty.

You may use the list clear() function to empty the list.

See the sample output below.

image text in transcribed

Part VIII: Delete Command

The delete command will remove items from the list. Your list manager must support the shortcut del command as well.

  1. The delete command will display all items with the index number next to each item.
  2. Use the pad_right() function to format the index column, with a space of two (2) blank spaces between the index and the list item value.
  3. The delete command will continuously prompt for data to delete until either all data is deleted, or the Enter key is pressed with no input.
  4. The delete command must validate the entered index is a valid integer, and the value is in the range appropriate for the number of items in the list.
  5. Use the strip() and string isdigit() (Links to an external site.) function to test if the entered index is a valid integer.
  6. Output appropriate error messages if incorrect data is entered.

See the sample output below.

image text in transcribed

Enter a command (? for help) : ? *** Available commands Add Add to list Delete Delete information List List information Clear Clear list Empty to exit Enter a command (? for help): list List contains 0 item(s) Enter a command (? for help) : Goodbye! Enter a command (? for help): add Enter information (empty to stop): Iteml Added, item count = 1 Enter information (empty to stop): Item2 Added, item count = 2 Enter information (empty to stop): Item3 Added, item count = 3 Enter information (empty to stop): Item 4 Added, item count = 4 Enter information (empty to stop): Enter a command (? for help): list List contains 4 item(s) Iteml Item2 Item3 Item 4 Enter a command (? for help): list List contains 0 item(s) Enter a command (? for help): clear 0 item(s) removed, list empty Enter a command (? for help): add Enter information (empty to stop): Iteml Added, item count = 1 Enter information (empty to stop): Enter a command (? for help): clear 1 item(s) removed, list empty Enter a command (? for help): Enter a command (? for help): list List contains 4 item(s) Iteml Item2 Item3 Item4 Enter a command (? for help): del 0 Iteml 1 Item2 2 Item3 3 Item Enter number to delete (empty to stop): 3 0 Iteml 1 Item2 2 Item3 Enter number to delete (empty to stop): 2 0 Iteml 1 Item2 Enter number to delete (empty to stop): 1 0 Iteml Enter number to delete (empty to stop) : 0 All items deleted Enter a command (? for help): list List contains 0 item(s) Enter a command (? for help) : Enter a command (? for help) : ? *** Available commands Add Add to list Delete Delete information List List information Clear Clear list Empty to exit Enter a command (? for help): list List contains 0 item(s) Enter a command (? for help) : Goodbye! Enter a command (? for help): add Enter information (empty to stop): Iteml Added, item count = 1 Enter information (empty to stop): Item2 Added, item count = 2 Enter information (empty to stop): Item3 Added, item count = 3 Enter information (empty to stop): Item 4 Added, item count = 4 Enter information (empty to stop): Enter a command (? for help): list List contains 4 item(s) Iteml Item2 Item3 Item 4 Enter a command (? for help): list List contains 0 item(s) Enter a command (? for help): clear 0 item(s) removed, list empty Enter a command (? for help): add Enter information (empty to stop): Iteml Added, item count = 1 Enter information (empty to stop): Enter a command (? for help): clear 1 item(s) removed, list empty Enter a command (? for help): Enter a command (? for help): list List contains 4 item(s) Iteml Item2 Item3 Item4 Enter a command (? for help): del 0 Iteml 1 Item2 2 Item3 3 Item Enter number to delete (empty to stop): 3 0 Iteml 1 Item2 2 Item3 Enter number to delete (empty to stop): 2 0 Iteml 1 Item2 Enter number to delete (empty to stop): 1 0 Iteml Enter number to delete (empty to stop) : 0 All items deleted Enter a command (? for help): list List contains 0 item(s) Enter a command (? for help)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

Why do you think DeShawn is drinking so much?

Answered: 1 week ago

Question

Describe the concept of diversity and diversity management.

Answered: 1 week ago

Question

How does the EEOC define sexual harassment?

Answered: 1 week ago