Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python creating a histogram with a dictionary I'm writing a program that creates a histogram of the frequency of words that appear in a text

Python creating a histogram with a dictionary

I'm writing a program that creates a histogram of the frequency of words that appear in a text file.

I've gotten to the point where I'm able to read the text into a dictionary with the words and their frequency as the key-value pairs, but I'm not sure how to create a histogram of it.

For example: say the text file contains "hello hello hello world this this is a test". The dictionary would be {'hello': 3, 'world': 1, 'this': 2, 'is': 1, 'a': 1, 'test': 1}

I want the program to print:

hello: ***

world: *

this: **

is: *

a: *

test: *

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago