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
How many grams are in 100 pounds?
stepan [7]

Answer:

45359.2 grams are in 100 pounds

Explanation:

Hope this helped, Have a Wonderful Day!!

3 0
2 years ago
Read 2 more answers
What type of maintenance is required of a computer’s power supply to ensure that it remains in working order?
True [87]
<span>d. Clean any dust or debris from the air vents in front of the fans.</span>
5 0
3 years ago
Read 2 more answers
Given four inputs: a, b, c &amp; d, where (a, b) represents a 2-bit unsigned binary number X; and (c, d) represents a 2-bit unsi
Amiraneli [1.4K]

Answer:

z = a.c' + a.b.d' + b.c'.d'

Explanation:

The truth table for this question is provided in the attachment to this question.

N.B - a' = not a!

The rows with output of 1 come from the following relations: 01 > 00, 10 > 00, 10 > 01, 11 > 00, 11 > 01, 11 > 10

This means that the Boolean expression is a sum of all the rows with output of 1.

z = a'bc'd' + ab'c'd' + ab'c'd + abc'd' + abc'd + abcd'

On simplification,

z = bc'd' + ab'c' + ac'd' + ac'd + abc' + abd'

z = ac' + abd' + bc'd'

Hope this helps!

6 0
3 years ago
What types of issues can you most likely resolve by knowing how to access and use the control Panel?
andrezito [222]
Network issues; screen resolution and volume issues
8 0
3 years ago
Which of the following is not a negative environmental effect associated with cars? A. Deforestation B. Roadside litter C. Toxic
777dan777 [17]

Answer:

The answer to this question is the option "C".

Explanation:

In this question, the answer is option C. Which is river toxic pollution. This pollution is also known as Kim Kim river toxic pollution. In 2019 this pollution occurred in the water caused by unauthorized chemical garbage dumping in the river in Malaysia. The unauthorized dumping released poisonous fumes, affecting six thousand people are hospitalized in 2,775.

8 0
3 years ago
Other questions:
  • Tom only thinks about his own gain and does not care about the team objectives. What quality is he demonstrating? A. resourceful
    9·1 answer
  • Discuss 2D gameplay and how new platforms such as cell phones are taking advantages of this renewed market
    5·1 answer
  • What method of malware infection installs malware through use of a separate browser window that opens uninvited from a Web page?
    7·2 answers
  • Python provides a special version of a decision structure known as the ________ statement, which makes the logic of the nested d
    13·1 answer
  • When Web users enter the URL www.CIWcertified.com in their browser address bar, they can access the official CIW Web site at the
    6·2 answers
  • Who invented the ENIAC? More than one answer may apply.
    14·1 answer
  • I need help I have questions I need answers in coding html,css,js and python.Fast
    7·1 answer
  • What are the benefits and risks of a client-server network?
    5·1 answer
  • What is the name of the option in most presentation applications with which you can modify slide elements?
    7·2 answers
  • Describe how a user would interact with a smart-phone to do various tasks.Consider inputs and outputs.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!