Write a function charHistogram(filename: str) -> None that takes the file name of a text file and prints a text rendering of the histogram of the English letters that appear in that file. Specifically, your function will perform the following steps: Step 1: Calculate the frequency of each letter in the English alphabet, treating everything as lower case. This means, for example, the string "five I" contains 2 i's %3D Step 2: Display a histogram on the console using print to indicate the frequencies of all the letters. The histogram contains one line per letter, ordered from the letter with highest frequency to the letter with the lowest frequency. When multiple letters have the same frequency, the tie breaks by the ASCII values of those letters in which the letter with smaller ASCII value appears before the letter with larger ASCII value. For instance, if the frequencies of a and b are 5, then we display a first then display b on the next line. Only the letters with a nonzero frequency are displayed. The frequency of a letter is represented by the number of +'s. For example, if the letter b has frequency 15, we'll render b +++ single space and 15 +'s. +++, i.e., the letter b followed by a Hint: You are allowed to use sorted(obj) function that returns a sorted list of the iterable object obj (obj could be a list, a set or a tuple, for examples.) Example: Consider the first few words of the fa- mous filler text Lorem ipsum: Your character histogram code should print the following to screen: Lorem ipsum dolor sit amet, consectetur adipiscing e ++++++++++++++++++++++++ elit. Praesent ac sem lorem. Integer elementum t ++++++++++++++++++ ultrices purus, sit amet malesuada tortor S +++++++++++++++++ pharetra ac. Vestibulum sapien nibh, dapibus i ++++++++++++++++ a +++++++++++++++ nec bibendum sit amet, sodales id justo. m ++++++++++++ r ++++++++++++ u ++++++++++++ 1 +++++++++ n +++++++++ o +++++++++ C +++++++ d +++++++ p +++++++ b +++++ g ++ h ++ i + V +
Write a function charHistogram(filename: str) -> None that takes the file name of a text file and prints a text rendering of the histogram of the English letters that appear in that file. Specifically, your function will perform the following steps: Step 1: Calculate the frequency of each letter in the English alphabet, treating everything as lower case. This means, for example, the string "five I" contains 2 i's %3D Step 2: Display a histogram on the console using print to indicate the frequencies of all the letters. The histogram contains one line per letter, ordered from the letter with highest frequency to the letter with the lowest frequency. When multiple letters have the same frequency, the tie breaks by the ASCII values of those letters in which the letter with smaller ASCII value appears before the letter with larger ASCII value. For instance, if the frequencies of a and b are 5, then we display a first then display b on the next line. Only the letters with a nonzero frequency are displayed. The frequency of a letter is represented by the number of +'s. For example, if the letter b has frequency 15, we'll render b +++ single space and 15 +'s. +++, i.e., the letter b followed by a Hint: You are allowed to use sorted(obj) function that returns a sorted list of the iterable object obj (obj could be a list, a set or a tuple, for examples.) Example: Consider the first few words of the fa- mous filler text Lorem ipsum: Your character histogram code should print the following to screen: Lorem ipsum dolor sit amet, consectetur adipiscing e ++++++++++++++++++++++++ elit. Praesent ac sem lorem. Integer elementum t ++++++++++++++++++ ultrices purus, sit amet malesuada tortor S +++++++++++++++++ pharetra ac. Vestibulum sapien nibh, dapibus i ++++++++++++++++ a +++++++++++++++ nec bibendum sit amet, sodales id justo. m ++++++++++++ r ++++++++++++ u ++++++++++++ 1 +++++++++ n +++++++++ o +++++++++ C +++++++ d +++++++ p +++++++ b +++++ g ++ h ++ i + V +
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Python: Character Histogram
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY