Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a file named benfordturtle.py, you will write a Python program that will read in a filename from the user. The file will contain one

In a file named benfordturtle.py, you will write a Python 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. Important note: the Turtle Bar Chart. The main page shows a vertical bar chart rather than the required horizontal one. Also note, 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.

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.

Your program must be able to handle any file in the same format, including files not given here.image text in transcribed

image text in transcribed

Rounded Bars 1, 30.1 2, 17.6 3, 12.5 4,9.7 5,7.9 6,6.7 7, 5.8 8,5.1 9, 4.6

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

5. Have you any experience with agile software development?

Answered: 1 week ago