Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
bartleby
Concept explainers
Question
PLeae write in python
The populated contacts.txt file with at least 5 contacts
1 screenshot of executed code in command line/terminal window for the print address book option (either paste
into Word document or as an image)
1 screenshot of executed code in command line/terminal window for the search contact option (either paste into
Word document or as an image)
Transcribed Image Text:Objectives
> Using file input/output
> Processing records
> Practice with exceptions
Lab 4
Command Prompt-pyth...
-MENU--
Print Address Book (1)
Search Contact (2)
Add new Contact (3)
Delete Contact (4)
Quit (5)
Enter your choice
> PrintAddress Book
➤ fSearch Contact
>fAddContact
<
Problem
Create a program (addressbook.py) that will manage an individual's address book. The program should allow a user to add
new contacts, print the entire address book, search for a contact, delete a contact, and exit the program. These features
should work as follows:
Part 1:
Create a function named Menu to display the menu to the user that contains all the above options using numbers from 1
to 5 (see output above). In function fMenu, validate the user input. If validation fails, display a message to the user and
display the menu again. If validation is successful, return the user selected choice value from the menu.
Create the following functions and simply display the function name within each function (just for testing the menu in this
part):
>Delete Contact
Create function main which is used to orchestrate the entire program. In main, call function fMenu and store the returned
value in variable choice. Test the variable choice for its value and then call the corresponding function (which will print
the function name, for now).
For the exit option, ask the user whether they want to continue (y/n). If they would like to continue, then display the menu
and get input from the user. If not, exit the program. Validate the user input, and if the input is not y or n then ask the user
again whether they want to continue.
Test the functionality in this part before continuing.
Part 2:
Remove the print statements from the individual functions. Add the following functionality to each function:
Add new contact: For this option, get the name, street address, and city state zipcode (one line), from the user. Write add
them to a file contacts.txt. Write out the file such that all the information about an individual is on separate lines. For
example, the name "Mickey" and address "DisneyLand" should be on separate lines rather than on the same line.
Transcribed Image Text:Print the Address Book: For this option, print all the contents of the address book.
Each record should be separated by a line of hyphens (see output)
Search for a contact: For this option, ask the user for the name of the contact who
they are looking for. Based on the name, look for that individual in the file one line
Mary
at a time and, if they are found, display all the information for that individual. If the Almaden ave
San Jose, CA 90740
individual is not found, then display a message to the user saying "Contact [name]
not found" where [name] is the name that the user searched for.
Delete a contact: For this option, ask the user for the name of the contact who they
want to delete from the address book. There are two different methods:
23 Command Prompt-pyth...
enter your choice 1
Michael
1234 Test Ave
San Francisco, CA 94105
Suzan
45 Hope St
seryville, CA 94512
Do you want to continue) (y/n).
> Write the all contacts except the one to be deleted to a new file, then delete the contacts.txt file, and rename the
new file back to contacts.txt.
> Store the all contacts except the one to be deleted in a variable and then overwrite the file contacts.txt with the
content of the variable
Test this part using all menu options. Populate the contacts file with at least 5 contacts.
Part 3:
You may have already noticed that the file contacts is opened in multiple functions. Create a new function named
fFileOpen having the filename and the mode as parameters. Use the open method using the two parameters to open the
file and assign it into a variable. Return the variable back to the calling program. Use exception handling to test for the
condition when the file is not found.
Replace the open method in all the functions with the function call fFileOpen.
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 5 steps with 6 images
Knowledge Booster
Background pattern image
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
- True or falsearrow_forwardTell us about file extensions and why you think they're important. You can name three file extensions that you see in a random folder on your computer. You can also name the software programs that made them. Most of the file extensions should show up when you right-click on a file and choose properties from the pop-up menu (Microsoft Windows environment).arrow_forwardhow to fix thisarrow_forward
- Please write this code in one file and execute the same output. Make sure to show the full code and output in the terminal.arrow_forwardThe size of this video file is MB Note: This Details tab is from Windows properties of a video file. The Data Rate is for video only. The Bit rate is for audio only. The Total bitrate audio + video. The format of Length is HH:MM:SS. Therefore you need the Total bitrate and the Length of the video and finally convert it to MB. General Details Previous Versions Property Value ViucU Length 00:06:45 Frame width 1024 Frame height 768 Data rate 5746kbps Total bitrate 5810kbps Frame rate 30.00 frames/second Audio Bit rate 64kbps Channels 2 (stereo) Audio sample rate 44. 100 kHzarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education