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
Approximately what percentage of the world population owns a smartphone?
Usimov [2.4K]
The number of smartphone users is forcast to grow from 2.1 billion in 2016 to around 2.5 billion in 2019, with smartphone penetration rates increasing as well.over 36% of the worlds population is projected to use a smartphone by 2018, thats up from about 10% in 2011
5 0
3 years ago
A software computer error, is a error produced by the malfunctioning of a computer part. E.g. RAMImmersive Reader
Andru [333]

Answer:

? is this you question true or false because i dont know the answer yet

Explanation:

4 0
3 years ago
If you are feeling sick and you want to drive somewhere, you should
Ganezh [65]

Answer

Ask someone to drive you.

Explanation

When feeling ill, or even taking medication before driving Is dangerous for the driver and other road users  because it slows reactions and the ability to make rapid corrective actions while driving. Driving while sick  can also have the same effects on a driver as if they were drinking.

5 0
3 years ago
Read 2 more answers
What job title is used for the person who uses the server operating system to add and remove users, install software, and admini
yan [13]
System Administrator
7 0
3 years ago
What's internet reendorsement?
Soloha48 [4]
Good question. When one Endorces or "Hires/ payes" someone again for a job/thing they did. I think. :)
6 0
3 years ago
Other questions:
  • What software refers to the on authorized and illegal duplication or sale of software
    10·1 answer
  • Match each language to its use.
    7·1 answer
  • What is the gauge manifold made of
    14·1 answer
  • If you were to design a range of athletic shoes for various sports activities, what key factors would you consider during the de
    11·1 answer
  • Stephanie would like to know the average number of regular hours worked by her employees. In cell B11, create a formula using th
    8·1 answer
  • What is a fire wall and how does it work
    14·1 answer
  • The process of sending a result back to another part of the program is
    14·1 answer
  • 1. Who was the first lady programmer?​
    14·2 answers
  • What do people in the movie e.t think about the character E.T
    9·1 answer
  • MODERATOR DELETE MY ACC
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!