Lectures‎ > ‎

Lecture 04: Document Storage and Display

Document Storage and Display


Exercises

1. Entropy

Consider a text file consisting only of digits from 0 to 9 (see digits.txt as an example). Write a Python program to compute the lower bound on the number of bits per symbol one can reach on average when compressing such a text file.

2. Run Length Encoding and Decoding

  2.1: Write a program in Python that reads binary data from a file (see binary-data.txt as an example) and encodes that in a run-length representation. What compression ratio do you get? Save this to a file with .rle extension.
  2.2: Write another program that decodes the run-length encoded file written by the first program and restores the original data.

3. Rendering Fonts

  Execute the program pango-ex1.py. Modify the program to apply the attribute "Strike-Through" to the first quote, change the color of the second quote to green, and center-align the three quotes.
ċ
binary-data.txt
(0k)
Ilya Mezhirov,
May 11, 2011, 8:13 AM
ċ
digits.txt
(1k)
Ilya Mezhirov,
May 11, 2011, 8:13 AM
ċ
pango-ex1.py
(1k)
Ilya Mezhirov,
May 11, 2011, 8:13 AM
ċ
Ilya Mezhirov,
May 11, 2011, 8:13 AM
Ċ
Ilya Mezhirov,
May 11, 2011, 8:13 AM
Comments