Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I could really use some help on this Python 3+ program. The following text files are: city_all.txt: 1292 1076 188040 1579 3510 2597 3783 64690

I could really use some help on this Python 3+ program.

image text in transcribedimage text in transcribedimage text in transcribed

The following text files are:

city_all.txt:

 1292 1076 188040 1579 3510 2597 3783 64690 2386 1099 5772 561 3150 1236 2593 3270 1585 1042 4705 217 2743 181 1657 5709 1212 4285 1083 2147 2800 1833 5853 2299 1483 3465 4475 4065 7420 6103 1985 7561 1136 7580 1422 2751 6470 6048 3250 7444 3905 327 8676 4248 3128 2911 2380 1139 755 7041 23989 2 281 1194 2357 11746 870 3113 23537 7016 2119 16661 2084 2307 30952 10355 1097 1308 720 4764 3206 4206 1373 4944 35636 352 2119 3804 7678 2431 297 3991 248 539 854 3289 1483 2894 4528 2929 4275 1072 1703 1140 25883 2526 593 2047 823 2533 24051 30047 7563 3 307 1351 520 877 1121 1145 1713 16422 17134 856 16135 17791 109563 17593 4361 1743 3991 13940 6351 1497 1060 3063 1780 705 1604 4327 7034 228 3101 10663 4722 1509 3205 8305 1751 1143 492 0 234 3831 1312 758 2213 2972 2515 594 1072 563 851 2727 26016 2845 1265 5695 1263 2982 4702 836 4406 2681 1604 1553 365 3869 11108 1259 14545 6838 3350 30627 4973 8841 1645 10994 3192 1243 10371 878 2009 1550 2551 2416 1254 1213 1001 3621 74262 1834 3408 1283 2116 194 587 204 761 84094 994 759 3129 5886 5784 168 15175 1093 29999 4446 19900 850 1348 1291 4964 2149 3671 1885 7350 1869 1194 1827 1078 3071 1936 2474 993 21705 4683 591 3500 1182 1727 1526 509 4713 1812 2944 766 14547 1332 521 1320 2535 1623 25139 1692 1748 9479 1325 1690 2456 4569 550 551 1884 1011 667 3645 2360 19435 984 3858 476 4113 23994 948 9066 2635 459 2513 861 2573 1228 5579 1150 1910 792 4170 1029 503 927 2063 3008 1933 1734 11327 5250 2537 8810 4517 1218 1370 461 2047 1952 3307 7116 2657 2574 1116 3559 4070 177 1279 2671 3739 383 2719 2114 4634 2012 526 1286 305 1955 1212 4894 3353 3186 3141 2266 1699 723 4110 921 1636 31929 2084 889 3658 3695 1774 2497 5214 1171 777 4291 1658 47299 2688 1900 28210 6745 1999 3259 647 15736 3787 2356 3960 1013 2983 129699 9726 46985 6222 906 713777 386 933 3801 7865 2444 1497 1478 2054 2847 3665 555 2739 747 1896 1229 1483 838 781 2859 2033 10028 2022 48362 2988 554 1681 590 882 826 1964 2366 3546 57774 1675 2235 9060 153 2521 13598 1207 3513 1489 478 2723 10514 987 667 396 1578 281 8389 7708 1907 34663 2071 655 13498 2279 59515 680 3843 1903 30184 3259 913 1047 3097 465 9959 1510 2094 7482 5627 3726 2198 1173 932 3086 7903 8700 3460 4654 1317 2573 777 5504 8248 3865 1186 466 971 1137 270 3731 8662 1804 22423 2970 17476 2525 542 882 55224 6702 1396 456 457 1098 9971 712 2726 823 2689 1975 992 6759 2128 1283 690 11555 5827 8708 750 6102 15879 1873 1361 1417 2833 1303 919 1976 4400 2945 20081 9193 3753 1972 10856 5816 3606 2389 6084 1969 2261 607 2978 2075 840 891 2285 1632 2441 1362 79580 3478 495 493 269 624 21581 9383 1184 2470 1678 153 2510 2325 611 818 5782 1486 1301 2452 953 21501 2375 2419 2539 5020 949 2261 1107 8481 2139 2 1575 1066 901 1277 1928 2087 924 1406 349 32408 2141 4934 95 1307 1369 24587 3788 2493 11936 4375 29319 903 3645 9358 2333 330 4248 1027 11598 926 9652 661 1242 14144 2377 653 799 427 5387 4075 8126 5485 6250 113934 450 1632 2037 2578 2199 1606 9512 3038 3378 1354 90173 448 985 670 3810 295 1875 2885 1851 462 4734 8257 465 1861 1161 1203 8365 2855 3786 818 2888 9300 1656 2619 2724 3525 14236 1409 4664 1905 47 20428 320 9996 1882 531 4992 3878 1223 53362 343 10601 38144 335 2554 12711 1674 2786 4093 63 1051 3188 5895 1655 1500 1210 2220 957 3770 7955 8209 384 4411 732 6224 1 1107 2043 1824 13142 82 5786 1574 27692 5476 2116 2892 3330 1523 1491 136 63131 16314 2615 6489 1341 14641 2467 10 2827 1122 3562 712 2425 29694 1250 2541 3048 5684 1060 7884 1146 2115 1123 11770 455 290 3798 2905 1941 722 1930 2933 98153 3597 3896 1233 1960 656 11362 2096 2029 807 79740 3231 1645 2679 1743 2674 15178 1275 2554 2526 1403 1949 1561 20103 313 4735 4456 1095 760 1791 1883 1331 2910 13807 1210 2796 815 3987 1986 1791 5543 1932 4015 3311 1735 338 1041 844 1090 862 4208 1484 1709 1862 2720 34681 5758 1623 3248 387 1176 72125 4848 1424 3329 2161 781 13336 1043 1151 41070 26035 96796 2109 46292 20526 354 2551 1538 305 1834 614 31085 5173 1112 1964 7784 2326 1128 1274 722 821 276 1581 2629 2141 19821 40840 3306 25146 21355 2611 2773 862 1106 3317 3084 2466 4079 741 5133 12875 981 1434 2029 11394 2027 686 1595 2778 2963 1329 691 657 79 652 1605 21165 12616 914 14482 413 28821 6201 5557 9909 4105 9110 2017 7575 437 3015 3274 3446 6207 1530 1747 1575 1003 21133 5733 5379 968 626 587 571 1842 2646 3457 1045 94 1398 1736 5084 10945 1004 10694 2361 4998 15552 3343 1667 1071 10111 467 1744 2169 1884 2447 2457 43381 1603 1600 2199 3294 632 568 3471 4796 2856 14749 333 7049 1737 11825 1860 404 488 3505 4240 3088 6549 4354 826 4069 717 4885 1212 2126 12084 748 3573 10 2823 192 461 14697 797 1571 1503 1765 2991 551 6776 656 1773 10038 398 1849 241 5421 19202 733 939 119 806 5879 6997 2056 1959 1368 12927 4008 312 3482 2399 25369 1483 3102 82 14970 2948 27524 3248 3326 4944 2692 3883 1348 2735 575 1287 3216 7088 4503 665 4836 973 3973 10483 942 661 1370 7581 1146 2850 1469 3317 1455 2209 1361 9932 4073 7439 451 4768 4867 1831 3308 393 1509 420 41706 1042 336 3221 1157 1221 1040 2047 2391 1138 894 2159 3158 14300 665 1006 3956 9878 405 1305 1339 846 1117 957 888 245 3100 1001 2188 1428 455 1148 1466 416 2791 522 10640 9489 1851 67 59715 80980 1180 46610 5949 1329 10735 2452 2808 30019 2250 14321 821 3366 1836 67 925 1335 7993 4217 1489 0 2570 37508 2530 1884 33534 3959 2365 293 4675 253 2566 1554 1880 1095 10470 243 1383 3799 3088 14568 3147 1185 2827 843 231 1297 1470 1626 1939 6784 8616 4757 2463 15082 1765 1419 909 1061 1477 499 25877 3103 8730 212 4315 2291 1944 1452 248 3645 807 11776 1392 511 2070 773 157 1328 1567 492 9 3017 935 1593 5719 646 2388 1413 38401 7624 795 1161 5903 1816 4772 7811 4755 2282 326 882 3854 9299 2160 283 759 816 6583 3604 795 3778 395 6058 8252 3968 4766 804 1369 4189 3523 302 472 1936 3079 5078 3762 4084 16779 787 8267 71707 1113 9132 903 2600 6913 1609 4144 39688 1153 1968 4821 4311 1001 5310 1659 8245 2173 3735 1093 1292 3404 2668 825 4731 1467 232 2423 20733 1188 8521 5136 1763 2018 2023 35394 16256 2476 3712 347 1138 1757 953 843 1932 2601 40186 70995 2431 28497 5594 3218 3068 729 2024 3551 6999 3960 822 487 3285 48707 181 1408 12182 1848 1562 790 2204 2082 352 1714 5260 486 653 2671 1477 4520 1168 1437 10412 9074 1441 1764 3312 547 1687 464 10654 13058 751 1674 1997 556 1739 2840 687 2502 647 1751 10020 1349 4568 752 1215 923 2868 6820 2153 21918 3082 10715 6042 620 889 296 3292 438 8076 1853 219 605 2253 1316 1157 639 1459 1184 4614 144 759 2697 1828 3509 1284 5733 1848 3795 1891 749 4568 1173 2976 1179 2007 384 4009 2401 603 880 1056 134056 4507 17802 759 2949 213 22508 7783 14480 1126 6035 2697 3404 1829 481 9001 47 12332 1974 952 1464 2073 9549 1393 1950 1657 1659 7559 1050 5757 360 4081 4602 2351 714 150 3497 1601 1609 1403 15194 1050 1031 51508 1407 4400 3904 15378 18853 829 817 236 11985 281 947 1542 6164 3983 2588 2355 14663 160 1625 34932 8214 11599 14164 1172 859 71739 3115 1230 4249 2349 2801 1436 163 6226 6033 2579 3984 2542 10372 1417 13255 1515 1337 6238 21412 3815 2369 487 1888 567 52347 73804 4623 1755 2654 1864 1397 581 1195 2066 1839 5178 14691 3239 5670 1302 2363 2805 1720 1221 2175 1436 3070 5056 2218 17840 2961 1232 2858 1560 2180 2993 1010 3779 1316 3174 57236 8276 3537 1694 2706 2282 2287 369 2574 698 4659 1970 20317 2617 9357 3894 6817 3173 13336 1058 96942 5505 1491 255 14854 1742 20708 545 4978 582 3530 2053 4656 804 1537 1568 292 8006 3228 12486 2093 32442 3488 2312 19575 717 8599 2654 5433 5974 3528 441 561 489 1919 102434 1546 8621 1964 3029 855 1720 596 1214 924 2631 445 2202 3168 

city_part.txt:

 1292 1076 188040 1579 3510 2597 3783 64690 2386 1099 
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% ofthe 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 Pod Relative size of P(d 130.1% 217.6% 3 12.5% 4 9.7% 5 7.9% 6 6.7% 7 5.8% 8 5.1% 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, with one value per line. The program's output will be formatted for readability (see below)

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions

Question

Why do most people resist change?

Answered: 1 week ago

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago