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
ryzh [129]
3 years ago
8

1. Implement the function dict_intersect, which takes two dictionaries as parameters d1 and d2, and returns a new dictionary whi

ch contains only those keys which appear in both d1 and d2, whose values are a tuple of the corresponding values from d1 and d2.
E.g., dict_intersect({'a': 'apple', 'b': 'banana'}, {'b': 'bee', 'c': 'cat'}) should return {'b': ('banana', 'bee')}

2. Implement the function consolidate, which accepts zero or more sequences in the star parameter seqs, and returns a dictionary whose keys consist of values found in those sequences, which in turn map to numbers indicating how many times each value appears across all the sequences.

E.g., consolidate([1,2,3], [1,1,1], [2,4], [1]) should return the dictionary {1: 5, 2: 2, 3: 1, 4: 1}.
Computers and Technology
1 answer:
stich3 [128]3 years ago
5 0

Answer:

1  

def dict_intersect(d1,d2): #create dictionary

  d3={} #dictionaries

  for key1,value1 in d1.items():       #iterate through the loop  

      if key1 in d2:   #checking condition

          d3[key1]=(d1[key1],d2[key1])   #add the items into the dictionary  

  return d 3

print(dict_intersect({'a': 'apple', 'b': 'banana'}, {'b': 'bee', 'c': 'cat'})) #display

2

def consolidate(*l1):  #create consolidate

  d3={} # create dictionary

  for k in l1:       #iterate through the loop

      for number in k:   #iterate through  the loop                               d3[number]=d3.get(number,0)+1   #increment the value

             return d 3 #return

print(consolidate([1,2,3], [1,1,1], [2,4], [1])) #display

Explanation:

1

Following are  the description of program

  • Create a dictionary i.e"dict_intersect(d1,d2) "   in this dictionary created a dictionary d3 .
  • After that iterated the loop and check the condition .
  • If the condition is true then add the items into the dictionary and return the dictionary d3 .
  • Finally print them that are specified in the given question .

2

Following are  the description of program

  • Create a dictionary  consolidate inside that created a dictionary "d3" .
  • After that iterated the loop outer as well as inner loop and increment the value of items .
  • Return the d3 dictionary and print the dictionary as specified in the given question .

You might be interested in
Jennifer has been hired as a temporary employee at a local college. She is given a username and password to access certain parts
gulaghasi [49]

LAN (Local Area Network)

<span>Basically, to be precise, Intranet is an extension of LAN in which IP services like HTTP, TCP/IP and several other standard protocols are added. Intranet is a private internet network that is used to add internet like services in an internal LAN.</span>

4 0
3 years ago
Read 2 more answers
What is a credit card balance? A...The amount of interest you must pay the credit card company B...The required minimum payment
eimsori [14]
A because my sister told me and it was corecct
3 0
3 years ago
Which type of appliance can host several functions, such as antimalware, firewall, content filter, and proxy server
navik [9.2K]

Answer:

Web Security Appliance (WSA)

7 0
3 years ago
The numbers on the bottom of a typical check represent all of the following EXCEPT
Phantasy [73]
<span>These numbers indicate the account a check is drawn on and from which bank.</span>
5 0
3 years ago
Harry wants to change the background of all of his presentation slides. Which slide will enable him to make this change to all t
Mamont248 [21]

Answer:

The answer to the following blank is Theme.

Explanation:

To change themes in powerpoint:

  1. Firstly, click on DESIGN tab then, click in the Themes group.
  2. Then, choose one of the following themes.
  3. Then, under Custom, choose the custom theme to apply.
  4. Then, under Office, click the built-in themes and apply. If users goal is display the little to no color in the user's presentations then, apply the Office Theme.  
  5. After all, click the Browse for Themes, and then locate and then click the theme.
5 0
2 years ago
Other questions:
  • Marisol manages the online advertising campaigns for a chain of toy stores with both a physical and an online presence. Which Go
    7·1 answer
  • What is the next series of dragon ball super
    6·2 answers
  • The first computer (the eniac was how big
    8·1 answer
  • Consider an environment in which there is a one-to-one mapping between user-level threads and kernel-level threads that allows o
    7·1 answer
  • To the following is not a network connection LAM MAN SAN WAN
    9·1 answer
  • When protecting a worksheet all cells are locked by default.?
    10·1 answer
  • Who is a software engineer
    8·2 answers
  • Wearables, video playback and tracking devices can help athletes because
    15·1 answer
  • Which kind of typography focuses on the details of a character?
    10·1 answer
  • How are most databases organized?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!