← Previous Next →

Give the frequency of letters in the 'words' file

Created by Julien Palard



You should work on this exercise with your own installation of Python, on your computer. Learn how for Mac OSX or Windows.

Your script should be able to open a file named words.txt located in the same folder, compute the frequency of every ascii lowercase letters in its content, and display them according to this format:

b: 0.02
p: 0.02
a: 0.07
o: 0.05
s: 0.09
d: 0.03
i: 0.07
m: 0.02
c: 0.03

I do not care about the order, only the values. No more precision, no less precision, and I want the trailing zeros, meaning 1/2 should be printed 0.50.