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]
4 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]4 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
Differentiate between data and information ​
Mademuasel [1]
Data is an individual unit that contains raw materials which do not carry any specific meaning. information is a group of data that carries logical meaning. info depends on data.
5 0
3 years ago
Reference variables allow arguments to be passed by ____________.
son4ous [18]

Answer:

Reference

Explanation:

The Reference type variable is such type of variable in C# that holds the reference of memory address instead of value. Examples for reference type are classes, interfaces, delegates and arrays.

We can pass parameters to the method by reference using <em>ref </em>keyword

It’s mandatory to initialize the variable value before we pass it as an argument to the method in c#

For example,

int x = 10;  // Variable need to be initialized

Add(ref x); // method call

If you pass parameters by reference in method definition, any changes made to it affect the other variable in method call.

Here's a sample program:

using System;

namespace ConsoleApplication

{

   public class Test

   {

       public static void Main()

       {

           int i = 10;

           Console.WriteLine("i=" + i);

           Add(ref i);

           Console.WriteLine("i=" + i);

           Console.ReadLine();

       }

       public static void Add( ref int j)

       {

           j = j + 10;

           Console.WriteLine("j="+j);

       }

   }

}

Output:

i=10

j=20

i=20

7 0
3 years ago
Which one of the following characteristics or skills of a ScrumMaster are closelyaligned with coaching?Select one:
bixtya [17]

Answer:

A. Questioning

Explanation:

Questioning is the skill of a scrummaster that is most closely alligned with coaching, inspite of others.

3 0
3 years ago
Determine the “answer” to the formula according to the spreadsheet below: =SUM(A1:D1).
MariettaO [177]
When you are trying to solve a formula like this one, you need to consider the whole row in the spreadsheet, not just A1 and D1.
So, A1:D1 refers to the whole row, which means that you need to add A1+B1+C1+D1 = 2 + 1 + 5 + 3 = 11.
The answer to the formula according to this spreadsheet is 11. 
6 0
4 years ago
Read 2 more answers
Consider the acknowledgment for a packet with sequence number n. A __________ acknowledgment indicates that all packets up to an
antoniya [11.8K]

Answer:

cumulative

Explanation:

Acknowledgment acknowledges that receiver has correctly received a packets which implicitly informs the sender that the previous packets were already received correctly.

4 0
3 years ago
Other questions:
  • ​Case-Based Critical Thinking Questions​Case 9-1Melissa, a computer science engineering student, is learning the basics of progr
    11·1 answer
  • Which network component allows computers to communicate on a network without being connected directly to each other?
    9·1 answer
  • Write algorithm to find (a+b)^2=(a+b)*(a+b)​
    9·1 answer
  • A slideshow that accompanies an oral report is known as what?
    6·1 answer
  • To apply the StartSafe philosophy to preventing workplace violence, what are the three steps to follow? A. Plan for your job req
    12·2 answers
  • Consider the following code segment:
    14·1 answer
  • I want to make a game with a friend. I use visual studio code. How do I work on the game with him? Like can he edit the same tim
    10·1 answer
  • Which of the following describes all illustrations created by freehand?
    15·1 answer
  • Opposite word of reassembling​
    15·2 answers
  • How to add links in HTML? ​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!