CSC111 Homework 8 2011
--D. Thiebaut 20:23, 8 November 2011 (EST)
This assignment is due on 11/15/11 evening, at midnight. It will be easiest for you to work on this assignment on beowulf, and not on your laptop/desktop.
Problem: Working with Files
- Check this page out: http://www.nytimes.com/ref/movies/1000best.html
- (If this page is not available, you can see a cached copy of it on beowulf: http://maven.smith.edu/~111a/1000best.html )
- It contains, according to the New York Times, the 1000 best movies ever made.
- The whole Web page is available for you to download to your 111a-xx account. All you need to do is login to your 111a-xx account, and type the following command at the prompt:
getcopy 1000best.html
- Check the contents of your directory with ls: you should see the new file. It is fairly large, and contains roughly 320,000 characters.
Your assignment
- Write a program called hw8.py that will
- ask the user for the year she was born in (or some other year),
- open the html file, read it, and output all the movies that came out in that year, sorted in alphabetical order.
- store this list to a text file, called movies_nnnn.txt, where nnnn will be the year selected by the user.
Example
- The user input is underlined:
python3.2 hw8.py Selecting movies for which year? 1933 Cavalcade Dinner at Eight Duck Soup King Kong Little Women State Fair The Private Life of Henry VIII Zero for Conduct Saving movies to file movies_1933.txt
- At the end of the program a new file will be in the current directory, and its name will be movies_1933.txt