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
Yuri [45]
3 years ago
12

Define a function typeHistogram that takes an iterator ""it"" (representing a sequence of values of different types) and builds

a histogram showing how many values of each type appears in the next n elements in the sequence.
Computers and Technology
1 answer:
Alexeev081 [22]3 years ago
3 0

Answer:

def typeHistogram(it,n):

   d = dict()

   for i in it:

       n -=1

       if n>=0:

           if str(type(i).__name__) not in d.keys():

               d.setdefault(type(i).__name__,1)

           else:

               d[str(type(i).__name__)] += 1

       else:

           break

   return list(d.items())

it = iter([1,2,'a','b','c',4,5])

print(typeHistogram(it,7))

Explanation:

  • Create a typeHistogram function that has 2 parameters namely "it" and "n" where "it" is an iterator used to represent a sequence of values of different types while "n" is the total number of elements in the sequence.
  • Initialize an empty dictionary and loop through the iterator "it".
  • Check if n is greater than 0 and current string is not present in the dictionary, then set default type as 1 otherwise increment by 1.
  • At the end return the list of items.
  • Finally initialize the iterator and display the histogram by calling the typeHistogram.
You might be interested in
Imagine that you are creating a website for a client. How will you interact with the client, gather requirements, and update the
Arisa [49]

Answer:

Be polite and open to ideas

Explanation:

Before going make a list of things you need to know for sure. You could also provide some samples. Make sure you take many notes on what they want! Speak with your client and ask them how and when they want to be updated on progress, some might want to know once a week others may want to receive a progress report every day. Communication is always key and will always help you provide good service.

Hopefully, this helps!

4 0
2 years ago
Read 2 more answers
*hacked*
galben [10]

Hey Litz06,

Sorry that happened to you.

Try changing your password to something complicated so it’s more secure.

5 0
3 years ago
Data files whose records are always retrieved in sequence from the beginning of the file are known as
dimaraw [331]

Answer:

sequential files

Explanation:

Q:

Data files whose records are always retrieved in sequence from the beginning of the file are

A:

sequential files

3 0
2 years ago
Most of us have been using elements of Web 2.0 without even realizing it.<br> True<br> False
aleksandrvk [35]

Answer: True?

Explanation:

I’m pretty sure I’m new to that stuff

5 0
3 years ago
Match the description to the step in troubleshooting.
Digiron [165]
It should go 4 5 3 2 1
5 0
3 years ago
Other questions:
  • The two types of one-time-password tokens are ______ and ______.
    10·2 answers
  • What effect can camera tilt create? Do you think this is effective? Why or why not?
    13·1 answer
  • how much should an organization consider moving into the cloud before full outsourcing starts making more business sense
    14·2 answers
  • A vertical curve means that any change in the Aggregate Price Level will have what result?
    15·1 answer
  • You are building a gaming computer and you want to install a dedicated graphics card that has a fast gpu and 1gb of memory onboa
    15·2 answers
  • A client contacted you to request your help in researching and supplying the hardware necessary to implement a SOHO solution at
    5·1 answer
  • During the boot process, the computer performs a quick self diagnostic then loads the operating system into memory.... IS THIS T
    5·1 answer
  • Overview
    7·1 answer
  • Modern Computers compared to earlier computers are
    10·1 answer
  • A router is connected to a network 192.169.1.0/24 and network 192.168.2.0/24. The router is configured to use RIP and has learne
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!