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
HELP PLZZ WILL MARK BRAINLIEST
adoni [48]

Answer:

if you could capture another image of this work bc I cant make out some words I can barley make out words

4 0
3 years ago
What is the correct sequence in which a computer operates​
GrogVix [38]

Answer:

Booting is a startup sequence that starts the operating system of a computer when it is turned on. A boot sequence is the initial set of operations that the computer performs when it is switched on. Every computer has a boot sequence.

8 0
3 years ago
What command do you type in the search box to access the command line intrface in windows?
Whitepunk [10]
Cmd.exe



------------------------------------------
3 0
3 years ago
How has information technology made piracy possible
ololo11 [35]
Well, more and more people are buying products and then uploading them online so that other people, who may not have the money or just don't want to buy them can download them for free. Of course, this is illegal, however it is a common practice all over the globe. Even if you are not downloading, but rather just watching a show on a website where you don't have to pay for it - it is still piracy.
3 0
3 years ago
Which of the following BEST describes the relationship between the Boston Marathon bombing and biometrics?
ale4655 [162]

Answer:

Because of the newly developed biometric technology, the FBI was able to

quickly identify two suspects.

The blurry photos released by the FBI after the bombing prompted

researchers to improve their early biometric software.

Because biometric technology was unavailable at the time, the Boston

Marathon bomber remains at large.

The Boston Marathon bombing made researchers aware of how biometric

technology is sometimes useless and ineffective.

Explanation:

6 0
2 years ago
Other questions:
  • what type of authentication does the dod require to accesss sensitive data on mobile devices and /or email
    7·2 answers
  • It is a function that ends the connection to the database.
    9·2 answers
  • What are some situations where you might find it useful to use the “!” symbol in a program?
    9·1 answer
  • Applications software is also known as
    14·2 answers
  • A _____ is a number that summarizes an encrypted information. digital certificate hash function message digest hash algorithm
    8·1 answer
  • Write 4 types of viruses , explain them briefly.
    7·1 answer
  • few toffees were distributed among oriya , piyush and payal . priya got 3/8 , piyush and payal 1/8 and 1/2 of total toffees resp
    5·1 answer
  • A web application with an SQL server database is found to be compromised by an attacker. On examination, the email IDs of the da
    5·1 answer
  • The people, procedures, hardware, software, data, and knowledge needed to develop computer systems and machines that can simulat
    13·1 answer
  • Energy/power management systems, kitchen appliances, smart televisions, baby monitors, fitness trackers, and personal health mon
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!