Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 padding functions.

  • 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): Item4 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 Item 4 Enter a command (? for help): del 0 Iteml Item2 2 Item3 3 Item4 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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions