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
Ne4ueva [31]
3 years ago
14

The function below takes two arguments: a dictionary of strings (keys) to integers (values) a_dict and a list of strings key_lis

t. All of the strings in the list are keys to the dictionary. Complete the function such that it looks up each of the keys in the list and returns a list of their associated values. The order of the values in the list is based on the order of the keys in key_list. For example, with the dictionary {"puffin": 5, "corgi": 2, "three": 3} and the list ["three", "corgi"], your function should return [3, 2]. student.py
Computers and Technology
1 answer:
vitfil [10]3 years ago
8 0

Answer:

  1. def getData(a_dict, key_list):
  2.    result = []
  3.    for key in key_list:
  4.        result.append(a_dict[key])
  5.    
  6.    return result  
  7. result = getData( {"puffin": 5, "corgi": 2, "three": 3} , ["three", "corgi"])
  8. print(result)

Explanation:

Let's define a function <em>getData() </em>with two parameters,<em> a_dict </em>and <em>key_list</em> as required by the question (Line 1).

Since the function is to return a list of associated values of dictionaries, a new list,<em> result</em>,  is declared and initialized with empty values (Line 2).

Next, use for-loop to traverse through every string in the input <em>key_list </em>(Line 4) and use the traversed key to address the value in the<em> a_dict </em>and add it to the <em>result</em> list (Line 5)

At last, return the <em>result </em>list as output (Line 7)

We can test the function using the test case from the question and we shall see the output as follows:

[3, 2]

You might be interested in
HELP ME PLZZ FFFAAASSSTTTT
Dahasolnce [82]
The answer has to be A because we you get your licensed suspended you are un able to drive for a while Intel you take the test again and or pay a fine
6 0
3 years ago
Read 2 more answers
Which ribbon tab is not a default in Outlook 2016's main interface?
IRISSAK [1]

Answer:

view

Explanation:

i just know it

8 0
3 years ago
Read 2 more answers
______ devices are high-performance storage servers that are individually connected to a network to provide storage for the comp
natali 33 [55]
NAS - network attached storage
3 0
3 years ago
The digital revolution has affected a. almost all areas of movie-making, except makeup and hairstyling. b. only a small number o
Georgia [21]

Answer:

Option D is correct.

Explanation:

The Digital Revolution applies to technological improvements from optical automated and mechanical machines to that of the digital technology that is currently accessible. The era began well into the year of 1980s, and continues. That Digital Revolution still marked as the start of the Era of Info.

  • It's the evolution of electrical and analog to digital technologies.
  • Its the advent of digital technologies has also altered the manner of people communication.
  • The following things are only done through computers, cellphones, as well as the web.
5 0
3 years ago
Explain how communication is smooth and efficient working​
ohaa [14]

Answer:

To communicate effectively, you need to avoid distractions and stay focused. Inconsistent body language. Nonverbal communication should reinforce what is being said, not contradict it. If you say one thing, but your body language says something else, your listener will likely feel that you're being dishonest.

8 0
2 years ago
Read 2 more answers
Other questions:
  • Computers spend most of their time in loops, so multiple loop itera- tions are great places to speculatively find more work to k
    10·1 answer
  • In hunter-gather societies most hunting was done by
    9·2 answers
  • Which css property configures the capitalization of text?
    12·1 answer
  • One of the attributes in a table in your database depends on another attribute for its meaning. What type of dependency has been
    14·1 answer
  • using C++ to sort user input. for example, user enter 25numbers and sort them from small to big or big to small, cout thesamlles
    6·1 answer
  • Which of the following statements can be used as evidence that ancient Greek beliefs and art has been influential? Select the th
    9·2 answers
  • Default tab stops are set in word every _______ inch. a. ¾ b. ½ c. 1 d. ¼
    7·1 answer
  • Resumen sobre Tailandia​
    10·1 answer
  • There are many commercially made household linens found in the?
    7·1 answer
  • PLEASE HELP ME
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!