|
1 | | -# Playful Python |
2 | | - |
3 | | -Learning Python by writing silly programs and games. |
4 | | - |
5 | | -# Chapters |
6 | | - |
7 | | -## Chapter 1: Bottles of Beer |
8 | | - |
9 | | -## Howler |
10 | | - |
11 | | -## Chapter 2: Palindromes |
12 | | - |
13 | | -## War |
14 | | - |
15 | | -## Blackjack |
16 | | - |
17 | | -## Twelve Days of Christmas |
18 | | - |
19 | | -## Tic-Tac-Toe |
20 | | - |
21 | | -## Gematria |
22 | | - |
23 | | -## Ransom Note |
24 | | - |
25 | | -## Morse Encoder/Decoder |
26 | | - |
27 | | -## ROT13 |
28 | | - |
29 | | -## Musical Transposition |
30 | | - |
31 | | -## Hangman |
32 | | - |
33 | | -## Gashlycrumb |
34 | | - |
35 | | -## Movie Reader |
36 | | - |
37 | | -## Substring |
38 | | - |
39 | | -## Picnic |
40 | | - |
41 | | - |
| 1 | +# Playful Python Outline |
| 2 | + |
| 3 | +I aim to have 40-50 programs complete with specs, examples, inputs, and test suites. They won't necessarily have a specific order, but they will be grouped into easiest/harder/hardest categories. As many programs use common ideas (e.g., regular expressions, graphs, infinite loops), there will be an appendix section with explanations of how to explore those ideas. |
| 4 | + |
| 5 | +I have in mind a layout where each program gets four pages: |
| 6 | + |
| 7 | + 1 2 3 4 |
| 8 | + +--------+--------+ +--------+--------+ |
| 9 | + | | | | | | |
| 10 | + | | | | | | |
| 11 | + | | | | | | |
| 12 | + | illus/ | specs | |solution| notes | |
| 13 | + | info | | | | | |
| 14 | + | | | | | | |
| 15 | + | | | | | | |
| 16 | + +--------+--------+ +--------+--------+ |
| 17 | + |
| 18 | +1. If a short program, perhaps an illustration; if longer, maybe some background or hints. |
| 19 | +2. The `README.md` information (specs, example output) |
| 20 | +3. The `solution.py` contents |
| 21 | +4. Annotation of the solution with comments on lines, sections |
| 22 | + |
| 23 | +# Programs |
| 24 | + |
| 25 | +> "The only way to learn a new programming language is by writing programs in it." - Dennis Ritchie |
| 26 | +
|
| 27 | +The goal is to get the reader to become a *writer* -- to try to solve the problems. One technique in teaching is to first present a problem without showing how to solve it. Once the student engages with the problem, they find they want and need the object of the lesson. Each program is intended to flex some programming technique or idea like playing with lists or contemplating regular expressions or using dictionaries. By using `argparse` for the programs, we also cover validation of user input. |
| 28 | + |
| 29 | +## Easiest |
| 30 | + |
| 31 | +* **howler**: Uppercase input text so they YELL AT YOU LIKE "HOWLER" MESSAGES IN HARRY POTTER. (Could also be called "OWEN MEANY"?) |
| 32 | +* **jump_the_five**: Numeric encryption based on "The Wire." |
| 33 | +* **bottles_of_beer**: Produce the "Bottle of Beer on the Wall" song. Explores the basic idea of an algorithm and challenges the programmer to format strings. |
| 34 | +* **picnic**: Write the picnic game. Uses input, lists. |
| 35 | +* **apples_and_bananas**: Substitute vowels in text, e.g., "bananas" -> "bononos". While the concept is substitution of characters in a string which is actually trivial, it turns out there are many (at least 7) decent ways to accomplish this task! |
| 36 | +* **gashlycrumb**: Create a morbid lookup table from text. Naturual use of dictionaries. |
| 37 | +* **movie_reader**: Print text character-by-character with pauses like in the movies. How to read text by character, use STDOUT/flush, and pause the program. |
| 38 | +* **palindromes**: Find palindromes in text. Reading input, manipulation of strings. |
| 39 | +* **ransom_note**: Transform input text into "RaNSom cASe". Manipulation of text. |
| 40 | +* **rhymer**: Produce rhyming "words" from input text. |
| 41 | +* **rock_paper_scissors**: Write Rock, Paper, Scissors game. Infinite loops, dictionaries. |
| 42 | + |
| 43 | +## Harder |
| 44 | + |
| 45 | +* **abuse**: Generate insults from lists of adjectives and nouns. Use of randomness, sampling, and lists. |
| 46 | +* **bacronym**: Retrofit words onto acronyms. Use of randomness and dictionaries. |
| 47 | +* **blackjack**: Play Blackjack (card game). Use of randomness, combinations, dictionaries. |
| 48 | +* **family_tree**: Use GraphViz to visualize a family tree from text. Parsing text, creating graph structures, creating visual output. |
| 49 | +* **gematria**: Calculate numeric values of words from characters. Manipulation of text, use of higher-order functions. |
| 50 | +* **guess**: Write a number-guessing game. Use of randomness, validation/coercion of inputs, use of exceptions. |
| 51 | +* **kentucky_fryer**: Turn text into Southern American English. Parsing, manipulation of text. |
| 52 | +* **mad_libs**: TBD |
| 53 | +* **markov_words**: Markov chain to generate words. Use of n-grams/k-mers, graphs, randomness, logging. |
| 54 | +* **piggie**: Encode text in Pig Latin. Use of regular expressions, text manipulation. |
| 55 | +* **sound**: Use Soundex to find rhyming words from a word list. |
| 56 | +* **substring**: Write a game to guess words sharing a common substring. Dictionaries, k-mers/n-grams. |
| 57 | +* **tictactoe**: Write a Tic-Tac-Toe game. Randomness, state. |
| 58 | +* **twelve_days_of_christmas**: Produce the "12 Days of Christmas" song. Algorihtms, loops. |
| 59 | +* **war**: Play the War card game. Combinations, randomness. |
| 60 | + |
| 61 | +## Hardest |
| 62 | + |
| 63 | +* **anagram**: Find anagrams of text. Combinations, permutations, dictionaries. |
| 64 | +* **hangman**: Write a Hangman (word/letter-guessing game). Randomness, game state, infinite loops, user input, validation. |
| 65 | +* **markov_chain**: Markov chain to generate text. N-grams at word level, parsing text, list manipulations. |
| 66 | +* **morse**: Write a Morse encoder/decoder. Dictionaries, text manipulation. |
| 67 | +* **rot13**: ROT13-encode input text. Lists, encryption. |
0 commit comments