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
You need to install a customized console on 10 computers. what is the best way to do that?
ICE Princess25 [194]
So you're going to simply create, copy, and paste!  You're going to create your first console on the first computer, and the you'll be left with a .mmc file which you're going to copy and paste to the other nine.  As long as you can get that file over through a shared server connection, you should be fine!
6 0
3 years ago
Class 00 rubber gloves are used when working with voltages less than​ _____.
Radda [10]
Answer: 500 volts AC, 750 volts DC
Class 00 rubber gloves are given the color "beige" based on the color code of rubber gloves.
The proof test voltage for this class of rubber gloves is 2500 volts of AC voltage and 10000 volts of DC voltage
4 0
3 years ago
What two items must be given to the socket function in order to create a socket object? A) The socket type that will be used. B)
Yuki888 [10]

Answer:

The correct option are:-

a) The socket type that will be used

d) The socket family that will be used  

Explanation:

The socket() method generates the unbound socket in a networking domain and returns a descriptor of the register, which can be used in subsequent socket function calls.

The socket() method takes three arguments:  

Domain:- The domain for which a socket is to be built is defined.

Type:- The socket type to be generated is defined.

Protocol:- It specifies a common socket protocol to use. The protocol setting of 0 causes socket() to use a default uninstalled protocol that is suitable for the socket type requested.

5 0
3 years ago
Which of the following is best practice to minimize the chance of infecting your mobile device with malware
lawyer [7]
U Can use an anti virus, or do daily malware scans in ur device
7 0
3 years ago
The "A" in the CIA triad stands for "authenticity". True False
mihalych1998 [28]

Answer: False, the "A" in the CIA triad stands for <em>availability</em><em>.</em>

The CIA triad also know as the Confidentiality, integrity and availability triad, is known as a model which is designed in order to implement and enforce policies in regards to information security. This model is also referred as the availability, integrity and confidentiality model i.e AIC triad. This is done in order to avoid confusion with Central Intelligence Agency i.e. CIA.

8 0
3 years ago
Other questions:
  • Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with a
    13·1 answer
  • The MIQ inventory measures how much you value status. Which two measures are measures of status?
    11·1 answer
  • To execute a prepared SQL statement, you can use the _______ and execute methods of the PDOStatement object to set parameter val
    9·1 answer
  • Which sentences in the passage correctly describe a function?
    11·1 answer
  • In Windows Vista, the Run command can be found in which application?
    6·1 answer
  • Many software makers provide free downloadable updates, sometimes called a(n) ______ to users who have registered and/or activat
    5·1 answer
  • How many hosts are in each subnet?
    15·1 answer
  • Name two ways you can identify the pid number of the login shell.
    13·1 answer
  • In numpy to append two arreys vertically the function __ is used
    12·2 answers
  • Who designed the apple i computer in 1976?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!