Question: Complete the print_frequency_chart() function that takes a single dictionary parameter - letter_frequency. The keys of this dictionary are the letters of the alphabet in lowercase,
Complete the print_frequency_chart() function that takes a single dictionary parameter - letter_frequency. The keys of this dictionary are the letters of the alphabet in lowercase, and the values are the corresponding letter frequencies. You can assume that the dictionary will always have 26 keys, where each key corresponds to a letter of the alphabet (in lowercase).
The function should print out a vertical bar chart representing the letter frequencies. Each bar in the chart is made up of "#" characters, the number of which correspond to the letter frequency. The letters are printed at the base of the bar chart. Note that only letters with a frequency greater than 0 are included in the bar chart. Some examples of the function being called are shown below.
Hint: implementing helper functions may help simplify your solution.
letter_frequency = {'a': 16, 'b': 1, 'c': 6, 'd': 10, 'e': 18, 'f': 3, 'g': 8, 'h': 14, 'i': 13, 'j': 0, 'k': 1, 'l': 4, 'm': 4, 'n': 15, 'o': 12, 'p': 6, 'q': 0, 'r': 10, 's': 10, 't': 8, 'u': 2, 'v': 2, 'w': 6, 'x': 0, 'y': 5, 'z': 0} print_frequency_chart(letter_frequency) | # # # # # # # # # # # # # ## # # # ## ## # # ## ## # ## ## ## ## # ## ## ## ## # ## ### ## ### # ## ### ## ### # ### ### ###### # # ### ### ###### ## # ### ### ######## ## # ####### ######## ## # ####### ############ ###################### abcdefghiklmnoprstuvwy |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
