15.04.2013 Views

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9-15. Copying Files. Prompt for two filenames (or better yet, use command-line arguments).<br />

The contents of the first file should be copied to the second file.<br />

9-16. Text Processing. You are tired of seeing lines on your e-mail wrap because people type<br />

lines that are too long for your mail reader application. Create a program to scan a<br />

text file for all lines longer than 80 characters. For each of the offending lines, find the<br />

closest word before 80 characters and break the line there, inserting the remaining<br />

text to the next line (and pushing the previous next line down one). When you are<br />

done, there should be no lines longer than 80 characters.<br />

9-17. Text Processing. Create a crude and elementary text file editor. Your solution is menudriven,<br />

with the following options:<br />

1.<br />

2.<br />

3.<br />

4.<br />

5.<br />

create file [prompt for filename and any number of lines of input],<br />

display file [dump its contents to the screen],<br />

edit file (prompt for line to edit and allow user to make changes),<br />

save file, and<br />

quit.<br />

9-18. Searching Files. Obtain a byte value (0-255) and a filename. Display the number of<br />

times that byte appears in the file.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!