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
"Why learning how to type is so important.
djverab [1.8K]
The productivity of a business depends on how things are done faster. To complete your work faster it is important to develop typing skills. Typing helps you to work comfortably on the computer, it aids in communicating with colleagues and customers, creating documents, and finding new information.
Hopefully this helped.
8 0
3 years ago
What is a characteristic of an open software license
Darya [45]

Answer: Something people can change and share. It is usually given the bad name of have a bunch of fake information and bugs. Wikipedia is a good example of an open source website but it is not a program.

Explanation: An open source program is a program where you have free rein to basically do whatever you want to it.

3 0
3 years ago
In Outlook 2016, what happens when users begin to type in the To field the name of an email recipient to whom they frequently se
tino4ka555 [31]

Answer:

the email will automatically be listed

8 0
3 years ago
Read 2 more answers
Write a test program that prompts the user to enter a two dimensional array and displays the location of the smallest element in
alexandr1967 [171]

Answer:

def element_loc():

   is_end = 'n'

   dimen2 = []

   while is_end == 'n':

       par1 = input("Enter rows and columns: ").split(",")

       part = [int(i) for i in par1]

       dimen2. append(part)

       is_end = input("Do you want to add more rows? y/n: ")

   mini = list()

   for i in dimen2:

       mini. append(min(i))

   result = min(mini)

   row_index = mini. index(result)

   col_index = dimen2[row_index]. index(result)

   print("Row: ", row_index, "Col_index: ", col_index)

element_loc()

Explanation:

The python program solution above prompts users for the two-dimensional array and then the rows of the array are compared with the minimum value stored in another list or array. The row index and the column index are gotten from the mini and dimen2 arrays respectively and are displayed as the position of the minimum value in the two-dimensional array.

8 0
3 years ago
What are the two parts of a cell reference? column intersection and row range column range and row intersection column letter an
Natasha_Volkova [10]

Answer:

C - Column letter & row number

7 0
3 years ago
Read 2 more answers
Other questions:
  • Although the original BBS system was simple, it increased people's ability to communicate
    14·1 answer
  • Sam's manager would like him to create and distribute copies of a budget report for each department. The budget report should sh
    8·2 answers
  • Thomas asked his friend for a software suite. His friend had the software suite in his computer and he copied it into a small, r
    11·1 answer
  • In an AND truth table.
    7·1 answer
  • Multiply 1101 and 0110 in binary.
    10·1 answer
  • . Why use a sensitivity analysis?
    14·1 answer
  • Universal Containers has two customer service contact centres and each focuses on a specific product line. Each contact centre h
    7·1 answer
  • How does the technology work
    10·2 answers
  • Write a program that allows the user to continuously input the value n until a negative number is entered
    10·1 answer
  • True or false altering iso will affect the area of focus in a photo
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!