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
You have a web application hosted in AWS cloud where the application logs are sent to Amazon CloudWatch. Lately, the web applica
zhenek [66]

Answer/Explanation:

In this scenario, you can:

- look at the existing CloudWatch logs for keywords related to the application error to create a custom metric;

- create a CloudWatch alarm for that custom metric which invokes an action to restart the EC2 instance;

- create alarms that automatically stop, terminate, reboot, or recover your EC2 instances using Amazon CloudWatch alarm actions;

- use the stop or terminate actions to help you save money when you no longer need an instance to be running; and

- use the reboot and recover actions to automatically reboot those instances or recover them onto new hardware if a system impairment occurs.

Cheers

8 0
3 years ago
In social networking websites such as twitter, people leave narrow minded and subjective remarks and upload unacceptable videos.
koban [17]
The advice is That you Message Them To remind Them Those Type of posts are not appropriate if people on social Media say bad Things To you you block Them if people don’t Treat you nice
8 0
3 years ago
In the context of wireless signal propagation, the phenomenon that occurs when an electromagnetic wave encounters an obstruction
tresset_1 [31]

Answer:

Diffraction

Explanation:

Diffraction occurs when an electromagnetic waves encounter an obstruction and split in secondary waves, these waves continue the same direction that was split.

These waves going to around the object, obstacle with sharp edges could cause detraction, like tables, refrigerators chairs, walls, furniture, etc.

5 0
3 years ago
one business rule is that each project has one manager. Identify two (and no more than two) problems with the data structure or
Vinil7 [7]

Answer:

1. The data will not be tallying up - there will great variations and deviance.

2. There will be not enough data points

Explanation:

The management style, though it uses one manager, is not devoid of problems in the system. For example, there will be great difficulty in the collection of accurate data to properly define the system. This presents a great misinformation on the outcome of the data process. This is likely to be caused by the first factor that is the data having a lot of discrepancies. The discrepancy causes the data to be meaningless in terms of the trends displayed. In addition, the lack of enough points posses a challenge to the data collection and processing procedure. The data base management system can be used to concentrate data on a central point of reference.

3 0
3 years ago
We have written a method called sum with an int[] parameter nums. We want our sum method to compute the sum of nums, but our cod
ira [324]

Answer:

Following are the code to this question:

public class Main//defining a class-main  

{

public static int sum(int[] nums)//defining a method sum that accepts array  

{

int total = 0;//defining integer variable total

for(int num : nums) // use for-each loop

{  

total += num;//add array value in total variable

}

return total;//use return keyword to return the total value

}

public static void main(String []ar )//defining a main method  

{

int[] nums={1,2,3,4,5};//defining 1-D array nums

System.out.println(sum(nums));//use print function to call sum method  

}

}

Output:

15

Explanation:

In the class "Main", a static method, "sum" is defined, that accepts array in its parameter and inside the method, an integer variable "total" is define, that uses the for each loop to add array value in a total variable and use a return keyword to return its value.  

Inside the main method, an integer array nums are defined, that holds store some values and use the print function to call the sum method.

8 0
3 years ago
Other questions:
  • Question 9.9. Encryption is BEST described as
    12·1 answer
  • Which part of the os provides users and applications with an interface to manipulate files?
    8·1 answer
  • The two ways to use the help menu is by searching of the contents or searching the _____
    13·2 answers
  • Can you answer your own question on brainly?
    12·2 answers
  • The device used to connect a network to the internet is called a
    7·1 answer
  • Had you guys go to prom by yourself or someone in your senior class
    5·2 answers
  • Which router feature, when enabled, helps computers on the local network automatically discover and communicate with services pr
    12·1 answer
  • 3) Prompt the user for a 3-digit number, and the output should be the magical #, which is formed with each digit shifted to the
    13·1 answer
  • 1. Why are condition statements important for programming?
    11·1 answer
  • How was kapilvastu named​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!