1

LPTHW: Exercises 11 & 12 and a kale recipe

In exercises eleven and twelve, we move on from simple (and boring?) things like printing to getting data into our little programs.

Exercise 11: Asking questions

ex11
Zed explains that software is mostly 1) taking input from a person; 2) changing it; and 3) printing something to show how it changed. So far I’d just been printing strings, not getting any input from the user. In this exercise, I use raw_input to ask questions (…of myself) about basic facts.

Exercise 12: Prompting people

ex11aa
Exercise 12 demonstrates a new way to write the material covered in eleven, as shown above.

I also used the pydoc command to learn about raw_input, open, file, os, and sys, as directed. It’s certainly faster than Googling!

Finally, I wrote another little “form” to ask questions using the new style:

12bpyFunny that the day I move on from simplest concepts, I’m sharing one of my easiest recipes! In fact, I’m not even sure you can call it a recipe, but rather a series of guidelines for success with kale. Yesterday I demonstrated how to prep it, so be sure to check that out if you haven’t already.

Today’s recipe is for kale with “four flavors”: hot, sweet, sour, and salty.

IMG_20150104_202112

Pictured above: organic vegan cane sugar, apple cider vinegar, red pepper flakes, fresh garlic, and soy sauce.

Kale with four flavors (serves two or one very hungry person)

  • one bunch kale, prepped as directed
  • as much chopped or minced garlic as you desire. I used four giant cloves.
  • tablespoon of oil
  • red pepper flakes, to taste
  • apple cider or rice vinegar, to taste
  • soy sauce, to taste
  • sugar, to taste

Warm oil in pan. Add garlic. Quickly cook til fragrant, about 30 seconds – 1 minute. Partway through, toss in some red pepper flakes. If garlic is cooking too quickly, remove from heat. Do not overcook and do not allow garlic to burn.

IMG_20150104_202138

Add cleaned kale and toss thoroughly to coat with garlic and red pepper flakes. Some of this garlic got a little browner than I would have liked because the pan was hotter than I realized, but I decided to share the image (and story) anyway to show you that even folks who have been cooking for a long time occasionally slip up. When this happens, just put a descriptive adjective in front of the noun when serving it: voila, it’s kale with crispy garlic!

IMG_20150104_202208

Sprinkle kale with apple cider vinegar, soy sauce, and sugar to taste:

IMG_20150104_202234

If you’re completely uncertain about this, start with a tablespoon of vinegar, two teaspoons of soy sauce, and a teaspoon of sugar. Mix well over medium, medium-high heat; kale should be wilting and releasing juices, cooking down significantly:

IMG_20150104_202309

Continue to toss thoroughly so that flavors combine. Taste for seasoning and add more of what you think is missing. This is your chance to experiment with strong flavors and discover what works for you!

IMG_20150104_201137

And there you have it: a lovely little bowl of kale that you seasoned to your own taste. Well done!

Bonus lesson: you can treat swiss chard and collards the same way, just vary the cook times. If kale takes about ten minutes to cook down, swiss chard will finish in 6 – 8 (it’s tender!). Collards will need around 30 (tougher!), and you might have to splash in a few tablespoons of vegetable broth. Make it happen!

3

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!