CSC111 Homework 8 2011

From dftwiki3
Revision as of 20:24, 8 November 2011 by Thiebaut (talk | contribs) (Example)
Jump to: navigation, search

--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

  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
 
Movies that came out in 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