Tag Archives: ppmmc

Programming, Probability, and the Modern Mathematics Classroom — Exercises Part 7

This post is part of the ppmmc series. Please make sure to have read the previous posts in the ppmmc series so that the context is understood.

In this part, we do a few things:

  • We write a program to figure out the frequency distribution of the letters in Leo Tolstoy’s Anna Karenina. As best as I can tell, the full text is available for free download at archive.org. (Please let me know otherwise.) If you grab the .txt file, save it with UTF-8 encoding.
  • We write a program to create a histogram for the letter frequency distribution. The final output is annak_lettersdist.txt.
  • We introduce the “continue” statement and we use more readily the “open” statement for file I/O.
  • We use sets, dictionaries, and lists. Can your students figure out what set(list(“abcdefghijklmnopqrstuvwxyz”)) does?
  • We use some string manipulation.

In a nutshell, we’ve hopefully learned a lot in the last few lessons and now we can start building more sophisticated programs!

Don’t hesitate to get in touch if you have questions or would like more information about setting up a workshop or training in your school.

Download: ppmmc_exercises_part7.pdf