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]
2 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]2 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
To ____ a public member function of a base class in the derived class, the corresponding function in the derived class must have
Norma-Jean [14]

Answer:

None of the mentioned options

Explanation:

  • If we define a method in a derived class with same declaration type as that of base class then it is said to be overriding a function which behaves differently which will depend on the object which is calling the method.
  • Option a,b and c are not any kind of methods we implement using coding.
  • Option d is done when number or data types of parameters are different than the declaration of the base type.

8 0
3 years ago
When would it be necessary to edit the information shown on an electronic business card?
Goryan [66]

Answer:

Really depends on your situation. If you specified, I'd have an asnwer

3 0
3 years ago
Read 2 more answers
PLATO
storchak [24]

Answer: here is the answer ☀️keep on shining☀️

Explanation:

5 0
3 years ago
Charles sends Julia text messages every morning insulting her appearance and threatening to hurt her. He writes unflattering des
aalyn [17]
What is the question?
4 0
2 years ago
Read 2 more answers
The IP address and the port are both numbers. Which statement is true?
Tema [17]

Answer:

A computer has one IP address and many ports.

Explanation:

6 0
2 years ago
Other questions:
  • Given a double variable named areaofsquare write the necessary code to read in a value , the area of some square, into areaofsqu
    9·1 answer
  • ____ is a utility that can verify that TCP/IP is installed, bound to the NIC, configured correctly, and communicating with the n
    11·1 answer
  • The Springfork Amateur Golf Club has a tournament every weekend. The club president
    7·1 answer
  • I can't find the errors! Could anyone help me please?!
    5·1 answer
  • I NEED HELP ASAP!
    6·2 answers
  • How can injection attacks be prevented? Check all that apply
    6·2 answers
  • A occurs when you reset a mobile device but retain your installed applications and personal settings
    10·2 answers
  • Create One print command in LOGO​
    12·1 answer
  • Immigrants are allowed to enter the country to work when they have a(n)
    10·1 answer
  • Which device allows users to directly hear data from a computer
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!