Skip to content
pramode edited this page Jul 30, 2011 · 1 revision

Exercises

  1. Write a Python program which will create a text file whose size is "N" bytes. The name of the file and the size "N" should be read from the input (or the commandline). What should be the data stored in the file? It can be anything. For simplicity, just fill up the file with "N" occurrences of the character 'A'.

  2. Use the above program to create a few text files of varying sizes. Then write another program which will print the names of only those files whose size is less than 100 bytes (use os.listdir, os.stat etc)

  3. Write a program to check whether the data contained in two files is exactly identical.

Clone this wiki locally