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

  How to remove your cousin from facebook search results

Research the privacy and security settings on Facebook and create a "User's guide" for your aunt to work through with your cousin.

  Describe what the prosecution was unable to prove

Describe what the prosecution was unable to prove based on the digital evidence found. Indicate whether or not you think this is a common problem with digital evidence and provide a rationale for your response.

  Write a function backwards which prints the number

Write a function backwards(int N) which prints the number N in decimal, but backwards. For example backwards(3197) should print 7913.

  Create a web page tags.aspx for viewing tags

Create a web page Tags.aspx for viewing tags. Use a GridView control to provide access to the list of tags in the database. Put checkboxes beside each tag.

  Show the code for reginas function

Carol has written a class called Rectangle with member functions getLength(), getWidth(), and calcArea() to return the associated data members.

  Build an eportfolio page to describe your work

Apply business information software for data visualization and analysis purposes - you will complete the set of tasks using Excel, and build ePortfolio

  What is the purpose of the instruction decoder

What is the purpose of the program counter?

  Draw the invoice in html for presentation on the web

To appreciate this flaw, imagine the changes that would be necessary to draw the invoice in HTML for presentation on the Web.

  Risk assessment of ict system

Risk Assessment of ICT System and Developing Computer Incident Response System on WAMP platform

  Electricity and magnieism state and explain ampere law

state and explain ampere law ? ltbrgtstate and explain biot savert law ? ltbrgtstate and explain ohm3939s law ?

  Write a simplecalculator class that has public methods

Write a SimpleCalculator class that has public methods for adding, subtracting, multiplying and dividing two doubles.

  How to prepare an implementation plan

Boardman Management Group manages the Baderman Island resort. They are considering whether to upgrade the word processing software recent in use at the resort or to buy a new word processing software application. Boardman plans to hire Smith Syste..

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