2009 109: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 1: Line 1:
http://www.danos.nl/teog
Looked at some examples:


In-class, doing Exercise
* http://www.danos.nl/teog
* http://www.misspelling-generator.org/


== In-class, doing Exercise 12.3 ==
Write a function called most_frequent that takes a string and prints the letters in
decreasing order of frequency. Find text samples from several different languages and see how letter
frequency varies between languages. Compare your results with the tables at http://wikipedia.org/
wiki/Letter_frequencies.
Recall the Historgram function from Chapter 9, p.105:
<source lang="python">
<source lang="python">
def histogram(s):
def histogram(s):

Revision as of 13:56, 9 December 2008

Looked at some examples:

In-class, doing Exercise 12.3

Write a function called most_frequent that takes a string and prints the letters in decreasing order of frequency. Find text samples from several different languages and see how letter frequency varies between languages. Compare your results with the tables at http://wikipedia.org/ wiki/Letter_frequencies.

Recall the Historgram function from Chapter 9, p.105:

def histogram(s):
	d = dict()
	for c in s:
		if c not in d:
			d[c] = 1
		else:
			d[c] += 1
	return d