LPTHW: Exercises 7, 8, 9, 10… and kale!

Hi folks! Welcome to 2015!!

I’ve got a lot of ground to cover with Learn Python the Hard Way before I give a talk on Coding with Knives at PyTennessee on February 8, so let’s get started!*

Today I’m covering exercises 7, 8, 9, and 10 in one post because the concepts/practice are pretty similar. Namely, getting practice typing in code and making it run!

Exercise 7: Mary had a little… Cheese Burger


Two points of interest in exercise seven: 1) use single-quotes for short strings, e.g., ‘a’, or ‘snow’; and 2) a line longer than eighty characters is considered bad style in Python. Good to know!

Exercise 8: a little song/poem

ex8pyExercise eight covers slightly more complicated formatting of a string. Zed explains how %r is the “raw” format for getting debugging info about code. It will return exactly what you type, unless it needs to shorten something to be more efficient (he gives the example of changing ” to ‘.)

Exercise 9: eight days a week


Exercise nine introduces two ways to make a string go across multiple lines: 1) the “\n” newline escape sequence; and 2) three double-quotes.

Exercise 10: purr purr purr


Exercise 10 shows us \t to tab, \n to split a line, and a tabbed list.


It also has, as a bonus example, this silliness. My comment gives you a pretty good idea of how I reacted when the code ran.

Now that we’ve breezed through these exercises, let’s move on to something else quick and simple: kale! But wait, you didn’t expect me to say kale, did you? Kale is this giant, leafy, floppy, dirty, messy vegetable that perhaps you’ve found a bit unapproachable in the market:


Kale is big.


Kale is dirty. Sandy, muddy, gritty, grimy. Especially if you get the good (organic) stuff.


But don’t let the combination of giant + dirty scare you off. Prepping kale is easy and fast.

Take one leaf at a time and grab it by the base.


Start at the bottom and pull upwards, stripping the leaf from the stem. Be firm and sincere!


Pull all the way to the top, so that you’re left with only the greens in your hand.

Tear into pieces and drop into a bowl to be washed.


See? easy! That took about two minutes.


Rinse thoroughly: at least three changes of water. The first two rinses will be extremely cloudy. Subsequent rinses should run clear (or slightly greenish from the chlorophyll, I guess). Be sure to swish vigorously with your hands to loosen and dirt, sand, or grit.

I used lacinato (sometimes called dinosaur) kale here, but you can use this same method with curly kale. Just strip the leaves from the stem, tear into pieces, rinse, and spin in a salad spinner to remove extra moisture, if desired. Easy, and unlike collards, no knife is required.

Kale is also super fast and easy to cook, but you’ll have to wait til tomorrow’s post to get my recipe for garlicky kale with four flavors (hot, sour, salty, & sweet). See you then!

*I failed to mention? Shame on me! That’s right, I’m totally thrilled and honored to be giving at talk at PyTennessee on my experience learning Python with Coding with Knives. The talk will be in the afternoon on Sunday, February 8 at the Nashville School of Law in Nashville, Tennessee. Learn more about the conference and register to attend here!