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
6.10.1: Modify a C string parameter. Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley.
Andrej [43]

Answer:

#include <iostream>

#include <cstring>

using namespace std;

void replacePeriod(char* phrase) {

int i = 0;

while(*(phrase + i) != '\0')

{

if(*(phrase + i) == '.')

*(phrase + i) = '!';

i++;

}

}

int main() {

const int STRING_SIZE = 50;

char sentence[STRING_SIZE];

strcpy(sentence, "Hello. I'm Miley. Nice to meet you.");

replacePeriod(sentence);

cout << "Updated sentence: " << endl;

cout << sentence << endl;

return 0;

}

Explanation:

  • Create a function called replacePeriod that takes a pointer of type char as a parameter.
  • Loop through the end of phrase, check if phrase has a period and then replace it with a sign of exclamation.
  • Inside the main function, define the sentence and pass it as an argument to the replacePeriod function.
  • Finally display the updated sentence.
6 0
3 years ago
You just bought a new hard drive for your computer to be used as a secondary hard drive to store all your files. After installin
nexus9112 [7]
1) You need to allow the Bios to detect it by changing Input devices in the Bios.
2) Allow Windows to install driver automatically, and your good to go. I have installed an second harddrive to my PC before.
7 0
3 years ago
Read 2 more answers
Write a function named print_sum that accepts three numbers as parameters and prints the sum.
OLEGan [10]

Answer:

Complete C++ code along with output and comments for explanation is provided below.

C++ Code with Explanation:

#include <iostream>

using namespace std;

// implement a function named print_sum which takes three input numbers of type int and returns the sum of these three numbers.

int print_sum(int num1, int num2, int num3)

 {

// initialize the variable to hold the value of sum

     int sum;

// add the three numbers and store the result in the variable sum

     sum = num1 + num2 + num3;

// print the sum of three numbers

     cout<<"The sum of three numbers is: "<<sum<<endl;

 }

// driver code starts here

int main()

{

// initialize the three input numbers

   int x,y,z;

// get the three numbers from the user

   cout << "Please enter number 1: "<<endl;

   cin >> x;

   cout << "Please enter number 2: "<<endl;

   cin >> y;

   cout << "Please enter number 3: "<<endl;

   cin >> z;

// call the function print_sum to calculate the sum

   print_sum(x,y,z);

   return 0;

}

Output:

Please enter number 1:

24

Please enter number 2:

13

Please enter number 3:

7

The sum of three numbers is: 44

7 0
3 years ago
Which elements are visible when a user opens a new PowerPoint presentation? Check all that apply.
ch4aika [34]

Answer:

- Title Text Placeholder

- Subtitle Text Placeholder

Explanation:

5 0
2 years ago
Which attribute is used to specify the URL of a web page in a hyperlink?
seropon [69]

Answer:

href

Explanation:

HTML is an acronym for hypertext markup language and it is a standard programming language which is used for designing, developing and creating web pages.

Generally, all HTML documents are divided into two (2) main parts; body and head. The head contains information such as version of HTML, title of a page, metadata, link to custom favicons and CSS etc. The body of the HTML document contains the contents or informations that a web page displays.

A website refers to the collective name used to describe series of web pages linked together with the same domain name while a webpage is the individual HTML document (single page) that makes up a website with a unique uniform resource locator (URL).

In Web design, the attribute which is used to specify the uniform resource locator (URL) of a web page in a hyperlink is href.

Href is an abbreviation for hypertext reference and it's typically used with the anchor tag to link to another portion of the same web page or other web page of the same website.

For example, the syntax for href is;

<a href="https://www-brainly-com">My Assignment Page </a>

4 0
3 years ago
Other questions:
  • Program Rock.java contains a skeleton for the game Rock, Paper, Scissors. Open it and save it to your directory. Add statements
    10·1 answer
  • How are modern computers different from eniac?
    5·1 answer
  • When can you access the BIOS setup utility?
    14·1 answer
  • If you have defined a class named SavingsAccount with a public static data member named numberOfAccounts, and created a SavingsA
    7·1 answer
  • Write a function that takes as input a single integer parameter n and computes the nth Fibonacci Sequence number. The Fibonacci
    8·1 answer
  • Write a program that uses an initializer list to store the following set of numbers in an array named nums. Then, print the arra
    10·2 answers
  • Does anybody know the answer to 5.7.5: Factorial of Code HS? I can’t figure it out
    14·2 answers
  • 1.The hardware that allows data to be transmitted from a computer along a telephone line to another computer at the other end is
    12·1 answer
  • What is a distinguishing feature of 5G mm Wave?
    9·1 answer
  • The _____ layer addresses how the software will execute on specific computers and networks.
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!