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
In 1971, Intel created and marketed the first microprocessor chip, called the Intel 4004. What was significant about this invent
PilotLPTM [1.2K]
The answer is D

<span>D) It allowed computers to be smaller because the chip allowed for the creation of computer components with varying capabilities.</span>
7 0
3 years ago
How are Action Buttons different than hyperlinks?
ipn [44]

Actions buttons are different than hyperlinks in many ways.

2)They are predefined shapes.

<u>Explanation:</u>

Action buttons are predefined shapes in the PowerPoint and can be used for moving between the slides of the presentation and for referring to the hyperlinks as well.

Action buttons have a predefined shape and that shape can be used to set the functionality of that particular button as a convention. Action buttons make up a strong presentation.

Action buttons can be invoked by clicking on them or just hovering over them and various sound effects can also be added on both the events to make the presentation more engaging and attractive.

8 0
3 years ago
Write the definition of a method printDottedLine, which has no parameters and doesn't return anything. The method prints to stan
Bond [772]

Answer:

public static void printDottedLine()

{

  System.out.println(".....");

}

Explanation:

The above written code is in JAVA and it is the method definition of the method mentioned in the question.Since the method returns nothing hence it's return type is void and it does not have any arguments hence there is nothing written in the parenthesis.In JAVA System.out.println is used for standard output and trminates them by newline.

3 0
3 years ago
Describe the difference between the circumscribed and inscribed options when using the AutoCAD Polygon command
marysya [2.9K]

Answer: Describe the difference between circumscribed and inscribed options when using the autocad polygon tool. Circumscribed draws the object around the circle while inscribed draws the object inside the circle. The Length is equal to 5.3151 and the Angle is equal to 41 degrees.

Explanation:

3 0
2 years ago
Suppose that in a 00-11 knapsack problem, the order of the items when sorted by increasing weight is the same as their order whe
frosja888 [35]

Answer:

Following are the response to the given question:

Explanation:

The glamorous objective is to examine the items (as being the most valuable and "cheapest" items are chosen) while no item is selectable - in other words, the loading can be reached.

Assume that such a strategy also isn't optimum, this is that there is the set of items not including one of the selfish strategy items (say, i-th item), but instead a heavy, less valuable item j, with j > i and is optimal.

As W_i < w_j, the i-th item may be substituted by the j-th item, as well as the overall load is still sustainable. Moreover, because v_i>v_j and this strategy is better, our total profit has dropped. Contradiction.

8 0
3 years ago
Other questions:
  • HELP NOW PLZZ/ Question: Complete the sentence with the correct response.
    11·1 answer
  • HELP I don't understand this
    14·2 answers
  • What is the keyboard shortcut Ctrl+Z used for?
    14·2 answers
  • Why is it important to develop a research plan?
    5·1 answer
  • What is "the last mile of broadband access"? Why is this a problem and what kind of impact does it have on the business world an
    9·1 answer
  • MacBook Pro (2019) at 93% max capacity battery rating after 100 charge cycles. Is this normal? Used coconut battery to check thi
    10·2 answers
  • Which company provides a crowdsourcing platform for corporate research and development?
    9·1 answer
  • Hiiiiiiiiiiiiiiiiii <br>i'm new here!!!​
    14·2 answers
  • Which of the following statements best explains how multitasking works in the human mind?
    11·1 answer
  • How would you explain how a password generator program works
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!