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
. Each ____ on a menu performs a specific action.
Fofino [41]
The answer would be d, none kf the above.
4 0
3 years ago
The two mathematical models of language description are generation and recognition. Describe how each can define the syntax of a
JulijaS [17]

Answer:

The correct answer to the following question will be "Semantic and Syntax error".

Explanation:

<u>Syntax error: </u>

Corresponds to such a mistake in a pattern sentence structure that is composed in either a specific language of that same coding. Because computer programs have to maintain strict syntax to execute appropriately, any elements of code that would not adhere to the programming or scripting language syntax can result inside a syntax error.

<u>Semantic error: </u>

That would be a logical error. This is because of erroneous logical statements. Write inaccurate logic or code of a program, which results incorrectly whenever the directives are implemented.

So, it's the right answer.

3 0
3 years ago
What permission do users have by default regarding printer access and the ability to manage documents?
Gnesinka [82]
<span>You can view documents across all print queues and print devices.

</span>
8 0
3 years ago
What are the two components that make up the chipset?
svet-max [94.6K]
Northbridge and Southbridge components.
6 0
3 years ago
What humidity level should be maintained for computing equipment? a. 50 percent b. 40 percent c. 60 percent d. 30 percent
sashaice [31]

Answer:

A. 50 percent

Explanation:

The correct option is - A. 50 percent

Another preventive measure you can take is to maintain the relative humidity at around 50 percent. Be careful not to increase the humidity too far—to the point where moisture starts to condense on the equipment.

8 0
2 years ago
Other questions:
  • Create a program that reads words.txt (link near top of our home page) in order to: determine the length of the longest word(s)
    14·1 answer
  • You receive a file named Project4.xlsx as an attachment to an email message. What do you expect the file to contain?
    8·1 answer
  • Most licensing agencies offer an orientation meeting for applicants who want to obtain licensing for a child care facility or a
    12·2 answers
  • What does it mean to say that two variables are negatively correlated?
    6·1 answer
  • I have tried installing "windows media player" on my computer but at a point, something disrupts its instalment or I am asked to
    7·1 answer
  • A disadvantage of using an arithmetic mean to summarize a set of data is that __________.
    13·1 answer
  • Identify the use of queue in the process of spooling output to a printer.
    15·1 answer
  • For each 8-bit data frame the layer uses a generator polynomial G(x) = x4+x2+ x+1 to add redundant bits. What is the sequence of
    11·1 answer
  • Pharming involves redirecting users to a fraudulent Web site even when the user has typed in the correct address in the Web brow
    7·1 answer
  • The difference between a dot matrix printer and a line printer
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!