Question

You should implement several functions that the Phone Contacts program will need Each function with take in data through the parameters (i.e., variables names listed in parentheses) and make updates to data structure that holds the contact information, return, or print information for a particular contact. The parameters needed are listed in the table below and each function is described below that 1. Make an empty dictionary and call it contacts. Where in your code would you implement this? Think about how and why we write functions. What do functions help us do? Would you want to put your dictionary in the global space? Why or why not? Using the function descriptions and parameters given below, implement these functions to work with your dictionary 2. 3. Test your code using the test code given below. This code should be implemented in a main() function and will test that you have coded your functions correctly. Keep in mind, some of your functions will return a value when called, and some wont. One function will produce output or will print something out. Pay attention to the descriptions given. Dont forget to call main() to start your program. Parameter definitions: # used consistently throughout the program Parameter NameParameter Description contacts first The data structure you will use to hold your contacts the first name of the person, which will be part of the key used to add and/or edit a contacts information the last name of the person, which will be the other part of the key used to add and/or edit a contacts information the email address of the person the phone number of the person the age of the person last email phone age For each of these functions, remember to add comments to your code describing in your own words what thev do** create contact function Parameters (put the parameters in your function in this order): contacts, first, last, email, age, phone

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please give the thumbs up, if it is helpful for you!!. Let me know if you have any doubts.


"""
Created on Wed Oct 18 09:04:03 2017

@author:
"""
def create_contact(contacts,first,last,email,age,phone):
contacts[first+' '+last]=[email,age,phone]
  
def update_contact_number(contacts,first,last,phone):
contacts[first+' '+last][2]=phone
  
def update_contact_email(contacts,first,last,email):
contacts[first+' '+last][0]=email

def update_contact_age(contacts,first,last,age):
contacts[first+' '+last][1]=age

def get_contact_number(contacts,first,last):
return contacts[first+' '+last][2]
  
def get_contact_email(contacts,first,last):
return contacts[first+' '+last][0]

def get_contact_age(contacts,first,last):
return contacts[first+' '+last][1]

def contains_contact(contacts,first,last):
if first+' '+last in contacts.keys():
return True
else:
return False

def display(contacts,first,last):
if first+' '+last in contacts.keys():
print(first+' '+last)
print('Email: '+contacts[first+' '+last][0])
print('Phone: '+contacts[first+' '+last][2])
print('Age: '+str(contacts[first+' '+last][1]))
else:
print('Contact does not exist.')

def main():
  
contacts={}
create_contact(contacts,"Katie","Katz","[email protected]",25,"857-294-2758")
create_contact(contacts,"Jim","Jones","[email protected]",19,"525-866-2749")
create_contact(contacts,"Sarah","Sanders","[email protected]",18,"593-026-2532")

update_contact_number(contacts,"Katie","Katz","907-536-2946")
update_contact_age(contacts,"Sarah","Sanders",19)
update_contact_email(contacts,"Jim","Jones","[email protected]")
  
#print(get_contact_number(contacts,"Katie","Katz"))
#print(get_contact_age(contacts,"Sarah","Sanders"))
#print(get_contact_email(contacts,"Jim","Jones"))
#print(contains_contact(contacts,"Katie","Katz"))
#print(contacts)
print("Creation of Jim Jones: {}".format("Passed" if contains_contact(contacts,"Jim","Jones") else "Failed"))
print("Creation of Katie Katz: {}".format("Passed" if contains_contact(contacts,"Katie","kaTz") else "Failed"))
print("Creation of Sarah Sanders: {}".format("Passed" if contains_contact(contacts,"Sarah","Sanders") else "Failed"))
  
print("Updating of Jim Jones: {}".format("Passed" if get_contact_email(contacts,"Jim","Jones")=="[email protected]" else "Failed"))
print("Updating of Katie Katz: {}".format("Passed" if get_contact_number(contacts,"Katie","Katz")=="907-536-2946" else "Failed"))
print("Updating of Sarah Sanders: {}".format("Passed" if get_contact_age(contacts,"Sarah","Sanders")==19 else "Failed"))
print()
display(contacts,"Katie","Katz")
print()
display(contacts,"George","Shaw")
  
main()

3 @author: 4 5 def create_contact (contacts,first,last,email,age, phone): contacts[first+ +last-[email,age , phone] 7 8 def

40 41 def main): 3 contacts y 44 create_contact (contacts, Katie, Katz, Katie.latz@nau.edu,25, 857-294-2758) 45 creat

Output:

IPython console | Console 1/4困 | [108] : work/HomeworkLib/python) Creation of Jim Jones: Passed Creation of Katie Katz: Failed Cre

Add a comment
Know the answer?
Add Answer to:
You should implement several functions that the Phone Contacts program will need Each function with take...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to...

    DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to add new phone contacts, display a list of all contacts, search for a specific contact by name, delete a specific contact. The program should provide the user with a console or command line choice menu about possible actions that they can perform. The choices should be the following: 1. Display list of all contacts. 2. Add a new contact. 3. Search for a contact...

  • python Implement function get_contact(contacts, name) that returns a string. The contacts and the name parameter are...

    python Implement function get_contact(contacts, name) that returns a string. The contacts and the name parameter are both type string. This function checks for the name string in the contacts string and returns that person's contact information. If the person is not found, the function returns, "name not in contact". Assume input is always valid. Assume the same name is not repeated in contacts. [You may use split(), range(), len() ONLY and no other built-in function or method] Examples: contacts =...

  • Problem: Contact Information Sometimes we need a program that have all the contact information like name,...

    Problem: Contact Information Sometimes we need a program that have all the contact information like name, last name, telephone, direction and something we need to know about that person (notes). Write a program in java language with GUI, classes, arrays, files and inheritance that make this possible. In the first layer, the user should see all the contacts and three buttons (add, delete, edit). *Add button: If the user click the button add, a new layer should appear and should...

  • language:python VELYIEW Design a program that you can use to keep information on your family or...

    language:python VELYIEW Design a program that you can use to keep information on your family or friends. You may view the video demonstration of the program located in this module to see how the program should function. Instructions Your program should have the following classes: Base Class - Contact (First Name, Last Name, and Phone Number) Sub Class - Family (First Name, Last Name, Phone Number, and Relationship le. cousin, uncle, aunt, etc.) Sub Class - Friends (First Name, Last...

  • Please help!! (C++ PROGRAM) You will design an online contact list to keep track of names...

    Please help!! (C++ PROGRAM) You will design an online contact list to keep track of names and phone numbers. ·         a. Define a class contactList that can store a name and up to 3 phone numbers (use an array for the phone numbers). Use constructors to automatically initialize the member variables. b.Add the following operations to your program: i. Add a new contact. Ask the user to enter the name and up to 3 phone numbers. ii. Delete a contact...

  • This assignment was locked Mar 24 at 11:59pm. For this lab you will implement a phone...

    This assignment was locked Mar 24 at 11:59pm. For this lab you will implement a phone book using a linked list to keep people's names and phone numbers organized in alphabetical order. 1. Define a structure to hold the contact information including: name, phone number, a pointer to the next node in the list. Example: struct ContactNode { string name; string phoneNumber; ContactNode *next; } 2. Define a class containing the structure and the appropriate methods to update and retrieve...

  • C++ In this assignment, you will write a class that implements a contact book entry. For...

    C++ In this assignment, you will write a class that implements a contact book entry. For example, my iPhone (and pretty much any smartphone) has a contacts list app that allows you to store information about your friends, colleagues, and businesses. In later assignments, you will have to implement this type of app (as a command line program, of course.) For now, you will just have to implement the building blocks for this app, namely, the Contact class. Your Contact...

  • In this assignment, you will create an application that holds a list of contact information. You ...

    In this assignment, you will create an application that holds a list of contact information. You will be able to prompt the user for a new contact, which is added to the list. You can print the contact list at any time. You will also be able to save the contact list. MUST BE IN PYTHON FORMAT Create the folllowing objects: ContactsItem - attributes hold the values for the contact, including FirstName - 20 characters LastName - 20 characters Address...

  • In this assignment, you will create an application that holds a list of contact information. You...

    In this assignment, you will create an application that holds a list of contact information. You will be able to prompt the user for a new contact, which is added to the list. You can print the contact list at any time. You will also be able to save the contact list. Must Be In Python Format Create the following objects: ContactsItem - attributes hold the values for the contact, including FirstName - 20 characters LastName - 20 characters Address...

  • USING THIS CODE: #include <iostream> #include <string> using namespace std; class Contact { //this class cannot...

    USING THIS CODE: #include <iostream> #include <string> using namespace std; class Contact { //this class cannot be viewed from outside of the private class. //only the class functions within the class can access private members. private: string name; string email; string phone; //the public class is accessible from anywhere outside of the class //however can only be within the program. public: string getName() const { return name; } void setName(string name) { this->name = name; } string getEmail() const {...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT