Question: Please write python code for this assignment please! Benford's Law Benford's Law (sometimes called the First-Digit Law) is an observation about the distribution of first
Please write python code for this assignment please!


Benford's Law Benford's Law (sometimes called the First-Digit Law) is an observation about the distribution of first digits in many data sets: the number 1 occurs as the leading digit about 30% of the time, while larger numbers occur in that position less frequently (for example, 9 occurs as the first digit less than 5% of the time). As noted on Wikipedia: This result has been found to apply to a wide variety of data sets, including electricity bills, street addresses, stock prices, population numbers, death rates, lengths of rivers, physical and mathematical constants, and processes described by power laws (which are very common in nature) d P(d) 1 30.1% 2 17.6% 3 12.5% 4 9.7% 5 7.9% 6 6.7% Relative size of P(d) 9 4.6% Develop a program which will allow you to experiment with Benford's Law. The program will prompt the user for the name of an input file, read the contents of the file and count the leading digits, and then display the results. For simplicity, the program will assume that the data file contains integer numbers, ith one value per line The program's output will be formatted as shown below (see below). Hint: use the header line to determine formatting values. Enter a file name: city_all.txt Digit Percent Benford Benford's Law Benford's Law (sometimes called the First-Digit Law) is an observation about the distribution of first digits in many data sets: the number 1 occurs as the leading digit about 30% of the time, while larger numbers occur in that position less frequently (for example, 9 occurs as the first digit less than 5% of the time). As noted on Wikipedia: This result has been found to apply to a wide variety of data sets, including electricity bills, street addresses, stock prices, population numbers, death rates, lengths of rivers, physical and mathematical constants, and processes described by power laws (which are very common in nature) d P(d) 1 30.1% 2 17.6% 3 12.5% 4 9.7% 5 7.9% 6 6.7% Relative size of P(d) 9 4.6% Develop a program which will allow you to experiment with Benford's Law. The program will prompt the user for the name of an input file, read the contents of the file and count the leading digits, and then display the results. For simplicity, the program will assume that the data file contains integer numbers, ith one value per line The program's output will be formatted as shown below (see below). Hint: use the header line to determine formatting values. Enter a file name: city_all.txt Digit Percent Benford
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
