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

ex7py

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

ex9py

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

ex10py

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

ex10apy

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:

IMG_20150104_201658

Kale is big.

IMG_20150104_201721

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

IMG_20150104_201900

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.

IMG_20150104_201930

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

IMG_20150104_201949

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.

IMG_20150104_202012

See? easy! That took about two minutes.

IMG_20150104_202035

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!

3 thoughts on “LPTHW: Exercises 7, 8, 9, 10… and kale!

  1. Pingback: LPTHW: Exercises 11 & 12 and a kale recipe | Coding with Knives

  2. Pingback: LPTHW 22: A balanced life | Coding with Knives

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s