Exit 1. Display a sorted list of guests 2. Add a guest to the list. 3. Delete a guest from the list.

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

PYTHON: For remote access, it’s often better to use a Command Line Interface (CLI), rather than a Graphical User Interface (GUI). A CLI does not use a mouse. However, a program can interact with the user via a menu driven interface. In this assignment, you will implement a menu driven interface for maintaining a list of guests. You will also validate user input to make sure that the name entered is not already in the list. Since some of the objectives of this assignment include demonstrating your proficiency with for loops, lists and the 'in' operator, please be sure to do the following:

  • use the list sort() method to sort your list
  • use a for loop to display each element in the list
  • be sure to create the list with three items already in it
  • use the title() string method for title capitalization

Not that all of the bullet items above are included in the Week 4 Exercises, including Supplemental Exercise 4, which is not in the book but is in this week's Canvas module.

Your program should provide a menu driven interface using a while loop in which the user can do the following:

0. Exit

1. Display a sorted list of guests

2. Add a guest to the list.

3. Delete a guest from the list.

Since names are strings and strings are case sensitive in Python, "joe" and "Joe" are different. Use title capitalization to convert names input to the user to title capitalization as described here: https://www.w3schools.com/python/ref_string_title.asp (Links to an external site.). This is needed when requesting names to be added and names to be deleted from the list. Also, make sure the initial names use title capitalization.

Program requirements

Create a list at the top of the program with three names, all using title capitalization.

Using a while loop, display the menu shown above and ask the user to make a selection using the input() command. Refer to the Session 4 Prezi, Slide 3.4.

If the user selects 0, then change the while loop condition so that the loop will exit.

If the user selects 1, sort the list and display each name on a separate line using a for loop.  Be sure to use the methods shown in Chapter 5 for sorting and displaying elements of the list.

Your program should demonstrate secure software best practices as follows:

  • Duplicate names are not allowed in the list. Before adding a name, make sure that the name is not already in the list by using the 'in' operator with an 'if' statement. Inform the user if a name is already in the list and do not add it.
  • An attempt to delete a name that doesn't exist in a list will throw an exception. When the user has entered a name to be deleted, first check to see if it is in the list, using the 'in' operator with an 'if' statement. If it isn't, inform the user and do not attempt to delete it.
  • If the user enters an invalid menu selection, inform the user that the selection was invalid and ask to please choose 0, 1, 2 or 3.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

The instructions were to use names or guests. Display guests, add guests, and delete guests. All while using title capitalization. Im am unusre why numbers were used as an example making the given solution very confusing to understand. The provided youtube video gives an idea on how the program SHOULD look:

https://www.youtube.com/watch?time_continue=1&v=i28wlElbaUs&feature=emb_logo

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Lists
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