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
Tuklasin<br>awain 2: Grapiko ng Pananagutan<br>Isulat sa graphic organizer pa​
mrs_skeptik [129]
What are you saying????
7 0
2 years ago
In a natural-language processing (NLP) system, the__________activity involves using the computer to read large amounts of text a
OleMash [197]

Answer:

Analysis is the right suitable word to complete the sentence

Explanation:

It is because, Analysis is a concept, which means to judge any subjects and brings some original concept which is needed to take from the subjects.

Here in the above question the paragraph states about the summarize points taken from a large amount of data and analysis also mean the same and analysis is also the activity used in NLP for the same as above discussed.

7 0
3 years ago
Given an list of N integers, Insertion Sort will, for each element in the list starting from the second element: Compare the ele
Elena L [17]

Answer:

def insSort(arr):

ct=0;

for i in range(1, len(arr)):

key = arr[i]

j = i-1

while j >=0 and key < arr[j] :

arr[j+1] = arr[j]

j -= 1

ct=ct+1;

arr[j+1] = key

return arr,ct;

print(insSort([2,1]))

Output of the program is also attached.

8 0
3 years ago
Using C#, declare two variables of type string and assign them a value "The "use" of quotations causes difficulties." (without t
stich3 [128]

Answer:

Let the two string type variables be var1 and var2.  The value stored in these two variables is : The "use" of quotations causes difficulties.

  • The variable which uses quoted string:

          string var1 = "The \"use\" of quotations causes difficulties.";  

  • The variable which does not use quoted string:

string var2 = "The " + '\u0022' + "use" + '\u0022' + " of quotations causes difficulties.";

  • Another way of assigning this value to the variable without using quoted string is to define a constant for the quotation marks:

const string quotation_mark = "\"";

string var2 = "The " + quotation_mark + "use" + quotation_mark + " of quotations causes difficulties.";

Explanation:

In order to print and view the output of the above statements WriteLine() method of the Console class can be used.

   Console.WriteLine(var1);

   Console.WriteLine(var2);

In the first statement escape sequence \" is used in order to print: The "use" of quotations causes difficulties. This escape sequence is used to insert two quotation marks in the string like that used in the beginning and end of the word use.

In the second statement '\u0022' is used as an alternative to the quoted string which is the Unicode character used for a quotation mark.

In the third statement a constant named  quotation_mark is defined for quotation mark and is then used at each side of the use word to display it in double quotations in the output.

8 0
3 years ago
Information that's been collected to help solve a problem is called
Butoxors [25]

Answer:

Data is the correct answer

5 0
2 years ago
Other questions:
  • 7.
    6·1 answer
  • A _____ captures the pattern in a _____ and sends it to the computer, where special software translates the _____ into meaningfu
    8·1 answer
  • To determine what to study, one should first
    8·1 answer
  • Write a shell script called SpellOutDate that prints the detail of the current date in separate lines. For example if the curren
    13·1 answer
  • Using a single formatting _______ helps to make reading researched information easier; it lets the reader know what to expect.
    7·1 answer
  • Which file system is designed to verify and autocorrect data faults on the volume without having to bring the volume down for ma
    11·1 answer
  • Write a program that uses nested loop or for statements to display Pattern A below, followed by an empty line and then another s
    5·1 answer
  • Which of the following is a good conductor of electricity and heat?
    13·2 answers
  • Create a method called randomValues that uses a while loop to generate a random number between 1-25 until the value 10 is genera
    12·1 answer
  • Write function d2x() that takes as input a nonnegative integer n (in the standard decimal representation) and an integer x betwe
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!