Question: Program using Python. Write a program that will read in a filename from the user. The file will contain one number on each line. Your

Program using Python.

Write a program that will read in a filename from the user. The file will contain one number on each line. Your program will compute the frequency (as a percentage of the whole) of the first digit of each number. Then it will use the turtle module to draw a horizontal bar chart. You are not required to define your own functions.

In terms of bar chart style, you may use bars like those shown in the Turtle Bar Chart link, or use a bar that is drawn using a single thick line. See examples below. Note: The colors are up to you.

Program using Python. Write a program that will read in a filenamefrom the user. The file will contain one number on each line.

Whichever bar style you choose, you must show the digit, and the frequency as text on the right-hand side of the bar.

One of the tricky things about drawing the bars is getting the length correct. However, the turtle module has you covered. The screen has a method named setworldcoordinates. that allows you to change the coordinate system being used. You are required to use setworldcoordinates to have the origin, (0,0), be set to the upper-left of the screen with a maximum x value of 100 (for 100%). The height is left to you.

Benford 1, 30.0% 2, 20.0% 3, 20.0% 4, 0.0% 5, 0.0% 6, 0.0% 7, 20.0% 8, 0.0% 9, 10.0%

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!