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
hammer [34]
3 years ago
14

Consider the following sequence of expressions: animals = {'a': ['aardvark'), 'b': ['baboon'), 'c': ['coati']} animals['d'] = ['

donkey'] animals['d'].append('dog') animals['d'].append('dingo')
We want to write some simple procedures that work on dictionaries to return information. This time, write a procedure, called biggest, which returns the key cor- responding to the entry with the largest number of values associated with it. If there is more than one such entry, return any one of the matching keys. Example usage: >>> biggest (animals) 'd' If there are no values in the dictionary, biggest should return None.

Computers and Technology
1 answer:
Eva8 [605]3 years ago
6 0

Answer:

Here it the Python program:    

def biggest(Dict):  #function definition

   big = None      #biggest key is initialized to None

   for key in Dict.keys():  #iterates through the keys of dictionary

       if big is None or len(Dict[big]) < len(Dict[key]):  #if big is none OR if the length of the Dict at big value (index) is less than length of Dict at key (index key) value

               big = key   #sets the key value as largest number of values and stores the key value to big variable

   return big       #returns the biggest key stored in big variable

animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati']}  #dictionary with keys

animals['d'] = ['donkey']  #adds donkey to dictionary and d is index key

animals['d'].append('dog')  #appends dog as item to the existing list

animals['d'].append('dingo')  #appends dingo as item to the existing list

print(biggest(animals))  //calls biggest method by passing animals to it as parameter in order to return in animals,  the key corresponding to the entry with the largest number of values associated with it

   

Explanation:

You can also write this program as:

The program works as follows:

Lets say we have this dictionary with keys and corresponding values

animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati']}

for key in Dict.keys():

this will iterates through the keys of Dict. Here animals = Dict

big is set to None initially

Now the if big is None or len(Dict[big]) < len(Dict[key]):  checks

len(Dict[big]) < len(Dict[key]):

Its none for len(Dict[big]) and 1 for len(Dict[key])

So big = key  sets the value of key to big  

Lets say aardvark is the value at that key index. So the key corresponding to this value is a. Hence

big = a            

As the dictionary order keeps changing so if you want to see what is the value at the specified key then you can use this statement;

print(Dict[key])

This will print ['aardvark']    

So this is how this loop works.

Now for the lines                          

animals['d'] = ['donkey']

animals['d'].append('dog')  

animals['d'].append('dingo')

This will add three items in the dictionary with key 'd'

So when length of len(Dict[key])) is 3. So whenever this is the highest length and so whenever print(biggest(animals))  is called, it displays 'd' in output because  Dict[key] is ['donkey', 'dog', 'dingo'] which corresponds to key 'd'. So this key corresponds to the entry with the largest number of values associated with it.    

The program along with its output is attached.

You might be interested in
"PindCart, an online retailer, places a small file on the computer hard drive of its visitors to recognize them when they revisi
photoshop1234 [79]

Answer:  cookie

Explanation:

  • A cookie is a small welcome file contains the information in the form og letters and numbers.
  • It is downloaded on to a computer when a website is visited.

Hence, if a company uses a small file on the computer hard drive of its visitors to recognize them when they revisit their Web site to generate a personalized welcome message to its visitors. This small file is called <u>a cookie</u>.

3 0
3 years ago
1) "Information systems are revolutionizing the way businesses function in the 21st century," Do you agree or disagree with this
alukav5142 [94]

Answer:

true

Explanation:

everything is computerized. banks, shopping, financial business records, ect

7 0
3 years ago
Select the characteristics that describe the evolution of computers that predate the personal computer (select all correct answe
emmasim [6.3K]

Answer:

Options (a), (b) and (d)

Explanation:

  • Option (a) is true that the computers have become smaller and smaller with advancement of the technology. The earlier version of computers used vacuum tubes and are very big in size.
  • As the years passed and due to the advancement of the transistors the computers have become smaller in size.
  • Option (b) is true. With the advancement in the research in circuits used in the computer like Integrated Circuits the computers have become faster.
  • The response time of the operating system has reduced drastically.
  • Option (c) is wrong option. The computers have become cheaper. The transistors are cheaper compared to the vacuum tubes which are used in the earlier computers.
  • The price of the same computer (memory and time efficiency) has become less in the coming years than in the previous years with the advancement in the research of transistors.
  • Option (d) is true. Now-a-days computers support more and more number of applications. Computers has more number of applications in various and diversified fields.
  • With the advancements in the computers, the computers are finding more applications in different fields like medicine, law, transport industries etc.
5 0
4 years ago
In which type of attack do you get malicious code in links from seemingly reliable websites?
natali 33 [55]

I think it is C. cross-site scripting

6 0
3 years ago
Please help me with question 1!
BaLLatris [955]

12,831 is the answer but if you care for the work then here it is:

Since its a percent then its a certain percentage of the whole. Therefore you take 13,650 x 94% or 0.94 which will give you the answer of the amount of people that are familiar with it.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Explain how to use fortran programming in details
    14·1 answer
  • When seeking information on the internet about a variety of subjects, the most useful place to look would be
    8·2 answers
  • What is the maximum amount that OSHA can impose as a penalty on an employer for each Willful violation?
    11·1 answer
  • One study found that nearly ____________ of the 1600 college freshmen surveyed had sent sexually suggestive texts or photos.
    11·1 answer
  • Which is better analog music or digital music
    15·2 answers
  • Count positive and negative number and compute the average. The program will have the user input an unspecified number of intege
    6·1 answer
  • All states that have altered judicial selection techniques in recent years have adopted some form of:
    5·1 answer
  • I really need this done Thank you!!
    6·1 answer
  • Electronic mail is best used to:
    5·2 answers
  • Im coding and need help please answer or comment to help. any skilled coders comment below
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!