Respuesta :
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:
The following are description of the program.
- 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'.
Dictionary, list, strings and integers are all data types of the Python programming language
The get_subset function in Python where comments are used to explain each line is as follows:
#This defines the function
def get_subset(mydict,myList):
#This declares the output dictionary
outputDict = {}
#This iterates through the loop
for item in myList:
#This checks if the current item exists in the dictionary
if item in mydict:
#If yes, the item is appended to the output dictionary
outputDict[item] = mydict[item]
#This returns the output dictionary
return outputDict
Read more about functions at:
https://brainly.com/question/14186324