Learning standard algorithms in Introduction to Python allows students to investigate the quirks of the English language.
We have two main goals in Introduction to Python, and sometimes it’s difficult to achieve these simultaneously. On the one hand, we want students to have fun, be creative, and enjoy the subject! Graphics-based programming is one way to reach this goal, and in my previous post for this class, I described some of the work we were doing with Python turtle graphics.
However, it is also important for introductory computer science students to learn some of the standard algorithms used to accomplish various tasks, and that was the emphasis of this class for the first part of block 3. In particular, given a list of integers, students learned how to write code to answer the following questions about the integers in the list:
- What is the arithmetic mean of all the integers?
- How many integers in the list are positive?
- What are the smallest and largest integers in the list?
- Are the integers in the list ordered from smallest to largest?
- Does the list contain duplicates? Or are all the integers in the list distinct?
Later in the block, to make this material more interesting and to allow for some creativity, students learned how to have their Python programs read information from an external text file. Students then wrote programs to read text files consisting of all the words in an English language dictionary, and answer various questions about those words. Some of these questions appear below. I wrote some of them, and others were created by the students. Answers (at least for the dictionary we used) appear immediately below if you'd like to try some of them!
- What is the longest word that is a palindrome?
- What is the longest word containing none of the letters 'a', 'e', 'i', 'o', or 'u'?
- What is the longest word whose letters are all in alphabetical order?
- In our dictionary, no word contains a double x. However, another letter appears doubled in exactly one word. What letter is that, and what is the word?
- What is the longest word consisting only of letters in the first half of the alphabet?
- "malayalam" (a language spoken in India)
- "symphysy" (the fusion of two bodies, or two parts of a body)
- "adelops” (a genus of beetles)
- Exactly one word contains a double q. It's "zaqqum", a tree referred to in the Quran.
- "hamamelidaceae" (a family of shrubs and trees)