Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program: Using Benfords Law to Detect Falsified Data (python) In an IDLE new window, create a program called benford.py. This program mainly consists of a

Program: Using Benfords Law to Detect Falsified Data (python)

In an IDLE new window, create a program called benford.py. This program mainly consists of a main() function and a call to main(). It must do the following:

Create a tally list that has nine elements, each of which is initially zero.

Prompt the user for the name of a data file and open it.

Use a for-loop to read each line in the file, splitting each line on the commas (line.split(,)) to create a list. The value after the final comma is the datapoint of which you want the leading digit. You should not make any assumptions about the number of spaces between the final comma and the datapoint at the end of the line, i.e., use strip() as shown above. (Note that you dont have to convert the datapoint to a string because its already a string. The entire 4 data file is made up of ASCII characters!) For the given digit, increment the tally list as appropriate. Dont forget to convert your digit to an integer.

Call the show digits() function after the tally has been completed. You may include this function in your code or else import it. If you import it, dont forget that it needs to be in your working directory or else in the path searched by Python.

Print tally.

Dont forget to include docstrings in your code!!! To test your code for a small data file, download pa6 test.dat from the homework Web page. You should get the following results:

import pa6

Enter file name: pa6_test.dat

Total number of datapoints = 13

Number of occurrences of leading digits: 5

digit measured predicted

1 1 4

2 1 2

3 1 2

4 1 1

5 1 1

6 1 1

7 2 1

8 2 1

9 3 1

[1, 1, 1, 1, 1, 1, 2, 2, 3]

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_2

Step: 3

blur-text-image_3

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago