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
Which method call converts the value in variable stringVariable to an integer?
zlopas [31]

Answer:

The correct answer for the given question is Integer.parseInt( string variable );

Explanation:

Integer.parseInt( string variable ); is the method in a java programming language that convert the string into the integer value. It takes a string variable and converted into the integer.

Following are the program in java which convert the string value into an integer value.

class Main  

{

 public static void main(String []args) // main function

{

   String str1 = "10009";

// variable declaration

   int k = Integer.parseInt(str1);

// convert the string into integer.

   System.out.println("Converted into Int:" + k);

}

}

Output:

Converted into Int:10009

Convert.toInt( stringVariable );

Convert.parseInt( stringVariable,Integer.toInt( stringVariable ); are not any method to convert the string into integer .

Therefore the correct answer is :Integer.parseInt( stringVariable );

3 0
3 years ago
Tamara has $500 she is looking to save for a class trip. She wants to earn the most possible interest and will not need access t
Novay_Z [31]
Certificate Of Deposit- It will be unaccesible and will help her the best.
6 0
4 years ago
Read 2 more answers
Assume you're using a three button mouse. to access shortcut menus you would
jekas [21]
<span>Normally you would click the right hand/secondary mouse button but you may configure any of the buttons to work within the Keyboard and Mouse section of System Preferences.</span>
7 0
3 years ago
Restore points are created at regular intervals and just before you install software or hardware by what utility?
AlexFokin [52]

Answer:

a

Explanation:

System restoration and it is a tool to return the status of the system to a selected point previously created by the user or by the machine after installing a software or an important event.

3 0
3 years ago
Which security procedure is being demonstrated if an administrator is using Wireshark to watch for specific inbound and outbound
defon

Answer:

The correct answer to the following question will be Option C (Firewall monitoring).

Explanation:

Firewall monitoring would be the analysis of essential firewall parameters that play a key role throughout the effective operation of firewalls.

Usually, management of the firewalls should include:

  • Monitoring the firewall file.
  • Management of the firewall statute.
  • Monitoring the design of the firewall.

Firewall security control is shown if the user uses Wire-shark to track relevant incoming and outgoing traffic.

Therefore, Option C is the right answer.

4 0
3 years ago
Other questions:
  • Assign to avg_owls the average owls per zoo. Print avg_owls as an integer. Sample output for inputs: 1 2 4 3
    7·1 answer
  • Steve is proofreading his memo and he notices that he has typed a phrase twice. Steve should _____.
    5·2 answers
  • There are a variety of common user interfaces. How would you decide which interface to use and on what should this decision be b
    11·1 answer
  • In a ring-based system, procedure p is executing and needs to invoke procedure q. Procedure q's access bracket is (5,6,9). In wh
    15·2 answers
  • Write a program that prompts the user to input a number. The program should then output the number and a message saying whether
    10·1 answer
  • The scope of a variable declared outside of any function is:
    11·1 answer
  • What is activated as necessary to support local eocs and to ensure that responders have the resources they need to conduct respo
    5·1 answer
  • Given an char variable last that has been initialized to a lowercase letter, write a loop that displays all possible combination
    8·1 answer
  • If Laura wanted to solve a problem using recursion where the last statement executed is the call to the same method, what type o
    8·1 answer
  • Who wrote the book of luke​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!