Help! With Python Programming Code - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help! With Python Programming Code (808 Views)
1 Reply
| Help! With Python Programming Code by onanugaf(op): 12:51am On Feb 24, 2010 |
I cant seem to figure out how to come up with a code to do the following assignment,can some one give me a guide.heres the assignment.I will appreciate all comments PROGRAMMING ASSIGNMENT 1. Download the file pidigits.zip from my web page. This contains the file pidigits.txt, a file that contains the first 1,000,000 digits in the decimal expansion of pi. Put this file in the same directory where your program is located. 2. The user of your program will enter 1 or more birthdays (1 per line) into the file birthdays.txt using the format mmddyy where mm represents the month of their birth (values between 01 and 12), dd represents the day of their birth (values between 01 and 31 and yy represents the year of their birth (values between 00 and 99). We’re going to ignore the ambiguity of a year such as 05 (Is it 1905 or 2005?). Note: this program should work for any 6-character number, not just birthdays. 3. Open results.txt for writing. For each birthday in the birthdays.txt file, your program will 1. Write the birthday to results.txt 2. Open pidigits.txt and find the occurrences of the user’s birthday and note the line number and position within the line of the beginning of each occurrence. Also output this information to results.txt. 3. If the birthday is not found, indicate that in results.txt. 4. Given the input shown at left, the contents of the results.txt file should be as shown at right: Input file: 022348 091290 112533 042209 120196 Searching for: 022348 line 16554 character position 13 line 17533 character position 37 Searching for: 091290 line 12988 character position 40 Searching for: 112533 line 28 character position 48 Searching for: 042209 line 20001 character position 28 Searching for: 120196 Date not found! Restrictions and Hints: 1. You must read only one line of pidigits.txt at a time. 2. At any given point in your program, you may not have a string longer than the sum of the lengths of the 2 longest lines in the file. In other words, you cannot simply read each of the lines in the file and concatenate them all together into a single string as a means of avoiding the first restriction above. 3. Your program must work correctly when the date crosses lines in the pidigits.txt file or is on the very last line (both cases tested with the data above). To process correctly, you must address the fact that each line has a newline character at the end of each line. You can ignore any case where the date is found more than once per line in pidigits.txt (only report the first). 4. Do not ask for file names. Code the names given above directly into your program. 5. It is expected that you will open, read, and close the pidigits.txt file for each date in the input file |
| Re: Help! With Python Programming Code by oradilo: 8:06pm On Feb 24, 2010 |
@ onanugaf Could you post a link to the webpage to download the pidigits.zip file, or upload the file in the forum? Maybe we can help you if you do that. Secondly, must your solution be implemented with Python? Well, I think you should be more concerned with developing an algorithm for your solution than searching for a coded solution (in Python). cheers |
| Re: Help! With Python Programming Code by Nobody: 8:24pm On Feb 24, 2010 |
the solution is easier than u think, just download the python manual from python.org and read the tutorials there. it's an assignment and it's wrong u asking for help |
Build A Bare Bones Reddit Clone With Python And Flask (hands On Tutorial Thread) • Pls Help With Python Problem • Python Programming • 2 • 3 • 4
I Need A Solution To My Pc Urgently • Nairaland Needs A Mobile App • What Is Your Personality Type You Programmer ?