Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment we will be reading and writing to files and creating a library that you will import for use in your main program.

In this assignment we will be reading and writing to files and creating a library that you will import for use in your main program.

Givens:

I have created a text file, Rumbers.txt, that contains 5000 random numbers. These numbers are stored in ten columns. The columns are separated by tabs and rows end with a newline.

You already have your isHarshad() function from assignment 1. We are going to use it here.

The Task:

You need to find/create three things

The sum of the Harshad numbers in Rumbers.txt.

An output file containing all the Harshad numbers with a 7 in the tens place (second column).

The numbers that are Harshad, that have a 7 in the second column and are evenly divisible by the constant Hodges. You will count these and print them to the screen, no need to save these to a file.

The Hows or What we need to see

You need to provide three files.

A file called myLib.py Inside this file should reside two functions, isHarshad() and isSiete(). isHarshad() will accept an integer and return True if the input is a Harshad number and False if it is not. isSiete() will accept an integer and will return True if the second column digit (The tens column) of the number is a 7 and False if it is not. Lastly, you are to create a constant variable called Hodges and set it equal to 14. All three of these items will be imported by your main program.

A main program called mainProg.py that reads in Rumbers.txt and creates the three deliverables above. This main program will open Rumbers.txt, import functions and the Hodges variable from myLib.py, do the processing necessary to find the solutions and create the output file we need, and then will close Rumbers.txt and the output file (see below). As output (to the screen) this program will print out the sum of the Harshad numbers (deliverable #1) and print the numbers that are harshad numbers with a seven in the tens column and are also multiples of the Hodges constant (deliverable #3).

An output file named HarshOut.txt that contains all of the Harshad numbers that have a 7 in their second column.

Rumbers:

8812 1816 9726 3463 2718 8880 5997 7686 6906 2857 3587 5587 1235 5680 1614 6259 4112 4832 3920 7099 3551 3062 9421 3918 3545 8129 7651 3156 97 302 4900 6843 3430 8075 9368 4878 2605 5839 595 895 288 4558 1321 7963 8477 2442 1348 6664 320 9463 6389 8274 3567 3880 6448 167 4226 4532 107 9984 305 5401 5396 9001 2153 2441 7820 9540 5264 7191 5653 7270 3571 8629 7176 1975 8445 3452 6177 7371 9899 9557 849 5943 9857 6182 5034 7046 2450 2807 9281 4592 4496 4717 2187 9607 9400 412 8102 4114 2600 8941 3153 643 8264 4249 4274 7423 7560 6930 4397 6835 5016 6232 5059 4919 4661 3774 1136 1167 3258 9231 6452 9294 7370 5053 811 6402 3859 9814 4794 4974 7453 2900 3996 1097 2561 5013 2945 210 1604 1446 9372 4035 6269 6891 9824 5969 758 2071 8927 5894 4979 8261 4978 6905 6535 9880 7264 2796 9760 6298 8581 6895 1485 3336 5194 9407 8107 2813 184 3607 8383 6341 2026 2448 1532 7407 7520 7252 2153 4554 8217 6703 3874 3961 8637 3572 8634 5379 6279 8872 9221 4337 8534 5308 8739 5657 5959 761 2787 9343 8662 4039 4627 5199 1448 1340 3039 1069 657 53 7482 746 2385 9538 9511 3372 8763 1956 4441 8299 9589 8193 8156 1636 1535 2500 1448 3108 14 3101 5834 9002 6511 126 9658 7214 5357 2191 9884 2355 8600 6967 3815 9225 3180 2936 5857 6890 3457 4518 5240 7578 468 9449 9654 8280 378 5552 9115 9806 376 1086 1136 9726 5249 249 3240 875 9018 2747 1002 3310 5424 7058 4259 7435 6602 5047 3282 6221 79 5409 2903 6673 5107 9037 3904 2277 1786 3210 3327 6582 905 6130 7731 7598 7000 9181 3751 2856 828 5859 2290 2735 7100 1919 836 6548 4739 8228 5023 5713 49 1486 5277 2376 2421 6702 6105 6622 8099 6615 4783 2436 7292 9760 3080 4380 3949 9353 6425 5174 706 9381 6777 5516 5498 3461 8297 7332 9322 9332 8346 81 5812 9197 3633 7870 2686 8384 1936 1000 3749 3533 4225 4911 7072 7319 9918 8585 7010 1377 6431 228 3178 7342 3287 7819 3606 8932 5991 8672 7545 1724 448 9700 6143 5833 7587 5337 9929 784 5215 8587 8209 2563 4650 9473 7518 7266 8368 6622 9740 1545 1782 3083 1189 4945 2965 3983 9523 968 4295 7458 4081 5790 1911 4742 1991 6831 5697 3927 8546 5652 5461 8671 9225 3263 1279 8314 9989 7842 8663 2557 4573 9448 796 1456 561 4348 8435 1817 3806 5531 9682 8827 2823 7035 8017 6844 3441 396 1452 4970 2110 5039 6099 879 3110 6474 1399 4084 4526 5095 2628 992 6775 2283 8659 9892 3061 6424 627 8666 8097 7573 7940 4799 9131 8155 7872 4854 4199 9826 2827 2591 9713 8923 9053 5608 6168 7191 5026 7170 1198 4796 1542 6540 5638 7851 8293 618 5781 4230 6959 4133 7320 2405 6748 7482 9605 9171 3380 3827 3541 8845 672 8958 204 401 6597 5179 392 2660 7023 2530 7225 8767 8055 351 4700 9036 4082 9338 1910 7423 6239 8429 656 2384 5216 9806 4591 4915 9032 4664 4789 4545

489 8217 1801 6177 9597 1424 7704 582 4711 7395 9959 8985 9315 7119 9988 7951 6002 9017 724 9962 4165 6312 3179 8761 3423 6224 6772 553 284 6234 6735 9810 1188 1084 9510 2948 7466 6064 6456 2947 9550 7860 9521 513 5173 9454 7552 2694 1721 8648 1682 3672 7822 739 8373 125 5142 5513 1907 4726 9036 4375 4313 6624 9034 3405 9264 3336 1287 6659 3638 870 3359 5143 7978 6920 603 6545 6898 5018 2661 7787 5200 749 3176 7750 7405 5670 1665 5850 2608 6717 9134 2200 6676 5510 7826 7923 8254 4368 2820 3117 7164 1708 5234 230 9460 1664 2989 7635 6144 3725 8483 5877 6586 3988 2832 2664 3185 4859 9287 7308 343 2816 5838 5972 792 2567 8063 3535 681 7633 5367 8485 9533 3040 5961 2846 1436 3275 7873 7707 7265 7739 3010 5045 8879 5851 7497 653 2798 2519 8851 4946 1466 4685 2844 4213 7335 9660 9831 9837 2900 3898 2068 2931 3510 5060 6957 4995 7459 1014 4950 7066 4564 2196 9360 7505 1829 9875 3268 8415 5728 7105 7798 4378 2189 7488 6547 5182 2128 9079 6668 2003 8066 7798 3533 9119 3535 9978 222 3253 2999 296 1154 4042 310 255 2148 6854 7285 7731 4087 3583 4448 3338 9517 122 4194 4503 8357 9742 4178 3852 9463 357 8313 7629 4301 8448 3439 709 2062 8319 7632 9943 3841 8733 2526 8488 1919 6821 7541 5459 6412 6217 9580 9279 5599 3259 9488 9473 962 9985 8224 3759 861 8112 5033 2776 6277 2619 8178 6089 4707 7981 4666 9443 4854 7440 9996 3110 3758 3613 5202 3334 8351 8548 8531 7693 7529 9288 3603 3981 7721 7770 4675 1170 4306 7270 5468 2864 4162 2452 1126 1267 2859 573 6805 5762 6604 7660 4 326 118 2660 5033 1490 4247 2243 5023 5730 3840 8337 7602 6061 2739 5018 1297 3949 6888 2888 2858 5158 2199 5926 3905 5334 740 3177 1210 1589 7625 8305 2951 8446 6406 2307 6993 4108 7960 5774 517 2221 2113 6361 865 3437 7472 7110 9047 6082 497 6742 9807 9305 7957 4193 243 9227 4449 4948 1816 2529 4854 5570 8252 8299 4817 3791 8106 6332 6349 4223 8293 7036 988 5121 1150 1998 7508 1513 3426 2486 4397 5320 6736 2496 4072 662 5750 3588 6975 3395 9859 1460 567 2159 3797 4489 7222 8602 6193 7338 4402 6869 6771 4714 1671 596 9789 4687 7520 5973 9919 3891 3747 8885 173 3430 7849 9752 6758 7981 9705 9950 8746 9076 6248 5960 8645 3162 8066 8686 5677 7904 52 4115 9502 1264 4223 8428 7129 8479 7938 6536 3100 1660 8445 385 5533 4606 7778 98 7644 1239 6468 7880 4741 9785 8657 4292 4772 679 8379 5932 8168 9795 5638 2702 3282 3727 5742 2710 5753 6087 8937 8019 3775 7451 1267 3364 9117 4716 2355 8306 7443 8265 9277 4160 1814 3983 6094 1230 1802 3435 3339 1444 3685 9406 2606 4871 31 9791 2791 3412 1417 4601 1217 8929 6023 389 3035 6270 8083 1267 9061 9829 7319 806 3005 3995 3948 2515 757 9597 6018 5630 6569 1714 653 6648 1068 1409 6341 5650 2573 1838 8310 5410

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

Name the ions from Exercise 6. In E 6 a. S b. Na c. H

Answered: 1 week ago

Question

4. What actions should Bouleau & Huntley take now?

Answered: 1 week ago