1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
gregori [183]
2 years ago
6

A friend of Kenneth's invited him to a party but forgot to give him the address. Luckily, Kenneth is very organized and has two

dictionaries, one that contains names and phone numbers; and another one that contains phone numbers and addresses. However, Kenneth needs your help to make it easier to find an address from a name. To achieve this, you will create a function called phone2address that takes three parameters:
⢠the first one is a dictionary that has names as keys and phone numbers as values
⢠the second one is a dictionary that has phone numbers as keys and addresses as values;
⢠the third one is a string with a friend's name.

To complete this function, you need to:

⢠First, use the phonebook and friend's name to find the desired phone number) .
Second, use the phone number and address book to find the correct address;
⢠Finally, you should return the address.
Computers and Technology
1 answer:
gregori [183]2 years ago
4 0

Answer:

Explanation:

The following code is written in Python and creates the function as requested in the question...

def phone2address(phonebook, addressBook, friendName):

   phoneNumber = phonebook.get(friendName)

   address = addressBook.get(phoneNumber)

   return address

The function uses the dictionary (phonebook) to look for the friendName input as the key and then saves the phone number attached to that name in a variable called phoneNumber. Then we use that variable to search the addressBook dictionary to find the associated address and save it to the address variable. Finally, we return that address.

You might be interested in
In java write a program:A contact list is a place where you can store a specific contact with other associated information such
BigorU [14]

Answer:

import java.util.Scanner;

public class ContactInformation

{

public static String GetPhoneNumber(String[] nameVec, String[] phoneNumberVec, String contactName, int arraySize)  

{  

for(int i=0;i<arraySize;i++)

{

if(nameVec[i].equals(contactName))  

return phoneNumberVec[i];

}  

return "Contact doesn't exists!";

}

public static void main(String[] args)

{

int records;

Scanner sc = new Scanner(System.in);

System.out.print("Enter the size of contact List :");

records=sc.nextInt();

String[] contactNameList=new String[records];

String[] phoneNumberList=new String[records];

String contactName;

System.out.println("Enter the contact name and phone number :");

for(int i=0;i<contactNameList.length;i++)

{  

contactNameList[i]=sc.next();  

phoneNumberList[i]=sc.next();  

}  

System.out.println("Enter the name of the contact to be searched :");  

contactName=sc.next();

System.out.println(GetPhoneNumber(contactNameList,phoneNumberList,contactName,records));  

}  

}

Explanation:

In the following the function defined above for getting the contact

number on the basis of contact number provided we are checking the contact name list if we are able to find the contact name and if we did we return the contact number on the same index from the contact number list

which we found in the contact name list.

4 0
3 years ago
What dynamic would best describe the genre of rock and roll?
Ainat [17]
Popular music characterized by vocals, hardback beat , loud volume and electric guitar :))) I really hope that helped if not let me know! :) <span />
3 0
3 years ago
In cell D5, enter a formula to calculate the number of days for the first workshop. Add 1 to the results to include the total nu
iris [78.8K]

Answer:

D7

Explanation:

5 0
3 years ago
Get ready to be the Quizmaster! You are going to design your own Python game show in the style of a quiz.
marin [14]

Answer:

"Are apples Magenta?"\n(a) yes\n(b) sometimes\n (c) no\n\n",

"Are apples Teal?"\n(a) yes\n(b) sometimes\n (c) no\n\n",

"Are apples Gray?"\n(a) yes\n(b) sometimes\n (c) no\n\n",

"Are apples Green?"\n(a) yes\n(b) sometimes\n (c) no\n\n",

"Are apples Cyan?"\n(a) yes\n(b) sometimes\n (c) no\n\n",

]

Questions(Question prompts[0], "a")

Questions(Question prompts[1], "c")

Questions(Question prompts[2], "c")

Questions(Question prompts[3], "c")

Questions(Question prompts[4], "c")

Questions(Question prompts[5], "b")

Questions(Question prompts[6], "c")

Questions(Question prompts[7], "c")

Questions(Question prompts[8], "a")

Questions(Question prompts[9], "c")

Explanation:

6 0
2 years ago
(True/False) Utilizing a higher bandwidth can support a larger volume of data (in bits per second) to be transmitted than a lowe
lions [1.4K]

Answer:

True

Explanation:

Bandwidth refers to the maximum data transfer rate across the communication media it refers to the amount of information sent for unit time and it's not related to the speed at which data is transferred (latency) but rather the amount of information. As an analogy imagine a full-pipe, the width of the pipe is related to the amount of water per unit time across the pipe (bandwidth).

3 0
3 years ago
Read 2 more answers
Other questions:
  • How do you transfer music from external hard drive to a laptop?
    13·1 answer
  • Given the following class import java.util.ArrayList; public class RectangleTester { public static void main(String[ ] args) { A
    7·1 answer
  • Describe the benefits and drawback of using virtualisation on a single machine and also in a cluster environment
    10·1 answer
  • If wire rope guard rails are used what must also be done?
    10·1 answer
  • You can count on everything online to be 100% accurate. <br> A. FALSE <br> B. TRUE
    11·2 answers
  • Use the Windows ________ to check on a nonresponsive program. Select one: A. Backup utility B. Task Manager C. System Restore D.
    10·1 answer
  • 334. Universal Containers uses a custom field on the account object to capture the account credit status. The sales team wants t
    12·1 answer
  • Using the simple alphabet code below, you will decode and encode the message. Write the Full
    6·1 answer
  • The cafeteria offers a discount card for sale that entitles you, during a certain period, to a free meal whenever you have bough
    13·1 answer
  • ____must cooperate with each other to neutralize the global threat of information censorship. Select 3 options.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!