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
Natali [406]
3 years ago
13

1 #Write a function called phonebook that takes two lists as

Computers and Technology
1 answer:
Nesterboy [21]3 years ago
7 0

Answer:

I am writing a Python program.

def phonebook(names, numbers):  #method phonebook that takes two parameters i.e a list of names and a list of phone numbers

   dict={}  #creates a dictionary

   for x in range(len(names)):  # loop through the names

       dict[names[x]]=numbers[x]  #maps each name to its phone number

   return dict #return dictionary in key:value form i.e. name:number

#in order to check the working of this function, provide the names and numbers list and call the function as following:

names = ['Jackie', 'Joshua', 'Marguerite']

numbers = ['404-555-1234', '678-555-5678', '770-555-9012']

print(phonebook(names, numbers))

Explanation:

The program has a function phonebook() that takes two parameters, name which is a list of names and numbers that is a list of phone numbers.

It then creates a dictionary. An empty dictionary is created using curly brackets. A dictionary A dictionary is used here to maps a names (keys) phone numbers (values) in order to create an unordered list of names and corresponding numbers.

for x in range(len(names)):  

The above statement has a for loop and two methods i.e. range() and len()

len method is used to return the length of the names and range method returns sequence of numbers just to iterate as an index and this loops keeps iterating until x exceeds the length of names.

dict[names[x]]=numbers[x]

The above statement maps each name to its phone number by mapping the first name with the first  umber, the second name with the second number and so on. This mapping is done using x which acts like an index here to map first name to first number and so on. For example dict[names[1]]=numbers[1]  will map the name (element) at 1st index of the list to the number (element) at 1st index.

return dict retursn the dictionary and the format of dictionary is key:value where key is the name and value is the corresponding number.

The screenshot of the program and its output is attached.

You might be interested in
What is the most efficient way to include a space after each paragraph
3241004551 [841]

To skip a line, then write the rest like this!


See? Good spacing, right?

4 0
2 years ago
The process of encoding messages or information in such a way that only authorized parties can read it is called ____________.
lukranit [14]

Answer:

Encryption

Explanation:

Encryption is a term in the field of computer security (Cryptology) this is a process of encoding information in a way that hackers and eavesdroppers cannot read. The process of encryption involves a plain text (message) been converted into a scrambled text (cipher text) with an encryption algorithm (key) in this way, if the message is intercepted by a hacker he/she is unable to read the contents. Only the authorized party with a decryption key will be able to decrypt back to a plain text and read the contents of the message

3 0
2 years ago
What additive keeps engines clean by preventing contaminates and deposits from collecting on surfaces? a. Friction modifiers b.
White raven [17]

Answer is: Dispersants


Explanation:

Dispersants keep contaminants (e.g. soot) suspended in the oil to prevent them from coagulating. Anti-foam agents inhibit the production of air bubbles and foam in the oil which can cause a loss of lubrication, pitting, and corrosion where entrained air and combustion gases contact metal surfaces.

So that's why the answer is: Dispersants

7 0
3 years ago
Read 2 more answers
What information on social networking sites could be used to discriminate against a potential employee
NISA [10]

the answer on plato is b

political affiliations

3 0
3 years ago
Complete the statement below with the correct term.
g100num [7]

Answer:

boot disk

Explanation:

This disk contains files required by the boot sequence as well as the operating system, which is loaded at the end of the startup process.

8 0
3 years ago
Other questions:
  • Which of the following option is correct about HCatalog?
    14·1 answer
  • A ____ is harmful computer code that spreads without your interaction, slipping from one network to another and replicating itse
    15·1 answer
  • What is the legal right granted to all authors and artists that gives them sole ownership and use of their words, software, pict
    9·2 answers
  • Malware that corrupts the target operating system in such a manner that a network defender can no longer trust the native OS is
    15·1 answer
  • A properYour customer has connected a 1000-watt microwave oven and a 600-watt mixer to a 15-amp branch service line for the kitc
    11·2 answers
  • When a compiler finds errors, it usually indicates what they are so you can correct the code and compile the program again?
    11·1 answer
  • With which type of social engineering attack are users asked to respond to an email or are directed to a website where they are
    9·1 answer
  • Which statement does not describe how to save a presentation?
    11·1 answer
  • Write a program that allows the user to enter a time in seconds and then outputs how far an object would drop if it is in free f
    7·1 answer
  • If the starting address location changes, in which of the following cases, the program has to be recompiled? Select one: a. Both
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!