Write a program that allows the user to add

Assignment Help Computer Engineering
Reference no: EM132211154

Question :

Write a program (PYTHON) that allows the user to add, delete and organize the items in a list.

Your program will provide the following options:

Append: adds an items, input by the user, at the end of the list.

Delete: removes an item indicated by the user from the list.

Move up: moves an item indicated by the user, to the previous position in the list.

Move Down: moves an item indicated by the user to the next position in the list.

Move Top: moves an item indicated by the user to the the first spot in the list.

Move Bottom: moves an item indicated by the user to the last position in the list.

Swap: swaps two items indicated by the user in the list.

List all: display the items in the list; one item per line.

Quit: allows the user to end the program.

Your program shall show appropriate error messages when trying to move, swap, or delete items not found in the list.

You program shall also properly handle invalid actions, like trying to move up the first item in the list, or trying to move down the last item in the list.

In order to get you started, download the file list_maintainer_base.py which you can find at the bottom of this page.

Here is a sample run. Let's assume we already added the following items (in this order): cake, cookies, ice cream.

Adding "donuts"

List Maintainer 3000 Menu: [A]dd item to the list, [R]emove item from list, [U] move an item up, [D] move an item down, [T] move item to the top, [B] move item to the bottom. [L]ist all items, [Q]uit program, [S]wap two items Enter an option: A [Add Item] Enter item: donuts ...Item added.
Listing all items

List Maintainer 3000 Menu: [A]dd item to the list, [R]emove item from list, [U] move an item up, [D] move an item down, [T] move item to the top, [B] move item to the bottom. [L]ist all items, [Q]uit program, [S]wap two items ?Enter an option: L [List All] 01 cake 02 cookies 03 ice cream 04 donuts
here is the code for the list:

def add_item(alist):
print("[Add Item]")
# Read a string from the user
# Add that string to the end of the list

def show_menu():
print('''
List Maintainer 3000
Menu: [A]dd item to the list, [R]emove item from list,
[U] move an item up, [D] move an item down,
[T] move item to the top, [B] move item to the bottom.
[L]ist all items, [Q]uit program,
[S]wap two items
''')

def read_option():
option = input("Enter an option: ").upper()
while option not in "ARUDTBLSQ":
print("Error: Invalid option. ")
option = input("Enter an option: ").upper()
return option


def main():
the_list = [] ##<--list to store user items

show_menu()
option = read_option()
while option != 'Q':
if option == 'A':
add_item(the_list)

elif option == 'R':
print("...remove item from list")

elif option == 'U':
print("...move item up")

elif option == 'D':
print("...move item down")

elif option == 'T':
print("...move item to the top")

elif option == 'B':
print("...move item to the bottom")

elif option == 'L':
print("...list all items")

elif option == 'S':
print("...swap two items")

else:
print("Bye!")

show_menu()
option = read_option()

main()

 

Reference no: EM132211154

Questions Cloud

What are the stages of product and service innovation : Why is operations management important in all types of organizations? What are the stages of product and service innovation?
Levels of power and influence that this leader achieved : Write a brief description of the leader you identified, including the levels of power and influence that this leader achieved.
Module opens with descriptions of three major companies : This module opens with descriptions of three major companies, each with its own distinct organizational culture: IBM, Google, and Apple.
Fredrick herzberg motivators and hygiene factors theory : Distinguish Douglas McGregor’s Theory X and Theory Y from Fredrick Herzberg's Motivators and Hygiene factors theory.
Write a program that allows the user to add : Write a program (PYTHON) that allows the user to add, delete and organize the items in a list.
Complete the given entries using given information : On February 3, 2017, FCM signed an agreement with Deion Sanders to provide media consulting for his football camp. On December 1, FCM completed some.
Display the frequency table of the characters in the file : Write a program that prompts the user to enter a file name, displays the frequency table of the characters in the file.
A program to prompts the user to enter the number of book : Write a program that prompts the user to enter the number of books that they are purchasing.
Write a program that prompts a user to enter a real matrix : Write a program That prompts a user to enter a real matrix A ofsize2x3 and a real matrix Bofsize 2 x 3 The program reads these two matrices.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd