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
diamong [38]
3 years ago
8

Define a function below, get_subset, which takes two arguments: a dictionary of strings (keys) to integers (values) and a list o

f strings. All of the strings in the list are keys to the dictionary. Complete the function such that it returns the subset of the dictionary defined by the keys in the list of strings. For example, with the dictionary {"puffin": 5, "corgi": 2, "three": 3} and the list ["three", "corgi"], your function should return {"corgi": 2, "three": 3}. Since dictionaries are unordered, you can add the keys to the new dictionary in any order.
Computers and Technology
1 answer:
frozen [14]3 years ago
3 0

Answer:

The following are the program in the Python Programming Language.

#define function

def get_subset(dic,lst):

   #declare dictionary type array

   res = {}

   #set the for loop

   for a in lst:

       #set the if conditional statement

       if a in dic:

           #assign the value of 'dic' in the 'res'

           res[a] = dic[a]

   #return the variable 'res'

   return res

Explanation:

<u>The following are description of the program</u>.

  • In the above program, define the function 'get_subset()' and pass two arguments in its parameter 'dic' and 'lst'.
  • Declare dictionary type variable 'res' then, set the for loop.
  • Then, set the if conditional statement that checks the elements of the variable 'a' in the variable 'dic' and assigns the value of 'dic' in the variable 'res'.
  • Finally, return the variable 'res'.
You might be interested in
A(n _______________ is a pre-written formula that is built into excel
nevsk [136]
<span>A function is a pre-written formula that is built into excel.
There are many functions which are pre-written into excel.
Some examples are the SUM function which adds the values in a given range. The AVERAGE function takes the average of values in a given range, etc.
</span>
8 0
3 years ago
What does a wholesaler do?
Svetach [21]
Wholesalers acquire goods from manufacturers, farmers or miners, holds them then distributes them to retailers.
6 0
3 years ago
A ________ is a device used to illegally capture the data stored on the magnetic stripe of an ATM card, credit card, or debit ca
Ksenya-84 [330]

Answer:

skimmer

Explanation:

8 0
3 years ago
Mark is learning to make logos. Once he finishes learning, he plans to freelance. Which software is most preferred to create art
MAVERICK [17]
Abode Illustrator helps to design logos in professional way
8 0
3 years ago
Write a public static method diagSum, which takes a 2d array of int values as a parameter, and returns the sum of the elements i
saveliy_v [14]

A 2d array (i.e. 2 dimensional array) represents its elements in rows and columns

<h3>The program in Java</h3>

The method in Java, where comments are used to explain each line is as follows

//This defines the method

public static int diagSum(int[][] myArray) {

    //This initializes sum to 0

    int sum = 0;

    //This iterates through each row of the array

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

                   //This calculates the sum of the diagonals

                       sum+=myArray[i][i];

               }

               //This returns the sum

               return sum;

       }

Read more about methods at:

brainly.com/question/15969952

6 0
2 years ago
Other questions:
  • What is authentication?
    8·1 answer
  • Consider the following network: proxy-cache On average there are 35 objects downloaded per second, and the average object size i
    14·1 answer
  • 11. John wants to share resources and move a large volume of data quickly over the Internet. John should use which of the follow
    14·1 answer
  • Write an algorithm in pseudocode (following the style of the Minimax pseudocode) that will always make an optimal decision given
    13·1 answer
  • Is there a syntax error in the following code? bool hourlyWorker = true; if (hourlyWorker) cout &lt;&lt; "The employee is an hou
    12·1 answer
  • At what x position are the ellipses drawn??? thanks ♡​
    6·1 answer
  • What is the difference between a workbook and a worksheet?
    14·2 answers
  • 2. How is accessing the Internet through a home network and public Wi-Fi similar?​
    15·1 answer
  • Write a program to enter length of a square and print area of square.<br>(class 8)​
    9·2 answers
  • besides entering a url to go directly to a website, what else can you enter in a browser address bar to explore the internet?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!