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
Thirty percent of a magazine's subscribers are female. A random sample of 50 subscribers Answer the following questions using Ex
Ann [662]

Based on the mean of the subscribers, the sample size, and the standard deviation, the probability of females being at most 0.25 is 0.2202.

The probability that they are between 0.22 and 0.28 is 0.2703.

The probability that they are within 0.03 of the population proportion is 0.3566.

<h3>What is the probability that they are at most 0.25?</h3>

Using Excel, we shall assume that the distribution is normally distributed.

We can therefore use the NORM.DIST function:


=NORM.DIST(0.25,0.3,0.0648,TRUE)

= 0.2202

<h3 /><h3>What is the probability that they are between 0.22 and 0.28?</h3>

=NORM.DIST(0.28,0.3,0.0648,TRUE) - NORM.DIST(0.22,0.3,0.0648,TRUE)

= 0.2703

<h3>What is the probability that they are within 0.03 of the population proportion?</h3>

X high = 0.30 + 0.03

= 0.33

X low = 0.30 - 0.03

= 0.27

= NORM.DIST(0.33,0.3,0.0648,TRUE) - NORM.DIST(0.27,0.3,0.0648,TRUE)

= 0.3566.

Find out more on probability at brainly.com/question/1846009.

8 0
2 years ago
Cylinder heads with four valves flow more air than those with two valves because they
Effectus [21]
Are able to hold more air
8 0
3 years ago
A credit card company receives numerous phone calls throughout the day from customers reporting fraud and billing disputes. Most
Veronika [31]

Answer:

3.59 minutes

Explanation:

We solve this question using z score formula

Using Excel

Z-SCORE= (DataPoint-AVERAGE(DataSet))/STDEV(DataSet)

IN EXCEL,

AVERAGE, an excel function that calculates the Average of data set

STDEV.S: calculates the standard deviation while treating the data as a ‘sample’ of a population.

STDEV.P: This function calculates the standard deviation while treating the data as the entire population.

Z score formula = x - μ/σ

x = ?? μ = 2.5 minutes σ = 0.5 minutes

We are asked : If 1.5% of the callers are put on hold for longer than x minutes, what is the value of x?

Hence, Longer than = Greater than =

100 - 1.5%

= 100 - 0.015

= 0.985 ( 98.5%)

Using Excel we calculate = z score for 98.5 percentile

= 2.1701

Z score = x - μ/σ

2.1701 = x - 2.5/0.5

2.1701 × 0.5 = x - 2.5

1.08505 = x - 2.5

x = 1.08505 + 2.5

x = 3.58505

Approximately to 2 decimal places = 3.59 minutes

Therefore, 1.5% of the callers are put on hold for longer than 3.59 minutes.

8 0
3 years ago
• R7.9 Write enhanced for loops for the following tasks.
alexdok [17]

Answer:

a is the correct answer

Explanation:

correct me if I'm wrong hope it's help thanks

3 0
3 years ago
19 dollar fortnite gift card
Ann [662]
Who wants it? ........
3 0
3 years ago
Read 2 more answers
Other questions:
  • Suggest ways in which web designers can use color to make a statement about the subject of a web page, a brand, or the website i
    12·1 answer
  • Technician A says that oil for the rod bearings comes from splash off the crankshaft. Technician B says that lubrication to the
    14·1 answer
  • Which programming element is used by a game program to track and display score information?
    10·2 answers
  • Critique and rank four different brands of antivirus software, rating them by price, functionality, and system requirements. Pre
    14·1 answer
  • This is really dumb but can someone help me find these memes? I can’t remember what they’re called but I remember how they went
    14·2 answers
  • FIRST ANSWER GETS BRAINLIEST IM GIVING 30 POINTS!!!! Select the correct answer. Emma's project team has to create an application
    12·1 answer
  • I can talk to you! How about we talk through the you know where people comment and say stuff about the question1
    10·2 answers
  • 4. Cash inflows from investing activities normally arise from all of the following EXCEPT
    14·1 answer
  • Which term refers to a shorthand method for identifying network and host bits in an ip address?
    14·1 answer
  • Which popular tool is used in agile software development TCS?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!