LPTHW: Exercise 3: Numbers and Math and caramelized onions

I use math a lot in my daily life. I’ve managed complicated budgets for several businesses (including my current job) and have been doing my own taxes (accurately!) for over a decade. Most of the time I’m in the grocery store I’m running numbers, determining sale prices, calculating total costs. Same goes for the kitchen — frequently I’m altering recipes, which requires an ability to do conversions on the fly.

Yet, when I saw that this exercise was about “numbers and math”, I froze. Numbers and math! It must be some basic, primal fear coming out. I’m glad I didn’t let it stop me:


Not so scary!

In the extra credit, Zed asks us to go back and comment out each line, explaining what is happening:


The only thing that tripped me up was modulus. In Zed’s words: “Another way to say it is, ‘X divided by Y with J remaining.’ For example, ‘100 divided by 16 with 4 remaining.’ The result of % is the J part, or the remaining part.” Okay.

He also has us start Python and use it as a calculator. I didn’t do anything too fancy:


Next up, he has us write another little .py file that does some math. I couldn’t figure out anything I needed to determine, so I just made something up.


I counted some hypothetical fruit. I’m looking forward to covering variables because I think it would have made my little example easier to write.

Finally, he stressed the importance of using “floating numbers” so I went back and re-wrote my little program to use them. Accuracy wasn’t an issue with this example, but it might be in the future, so floating point numbers seem like a good idea.

For today’s cooking basics lesson, I’m covering caramelized onions. Yesterday I made a pot of my favorite fordhook lima beans. The secret to their deliciousness is a generous base of caramelized onions.


Caramelizing means cooking over low-ish heat for a long time in order to brown the naturally-occurring sugars in the onions. The formerly pearly-white cubes are transformed into a rich golden-brown (or deeper!) color with a rich, savory-sweet flavor.


Start by uniformly chopping onions. A lot of folks go for long thin slices, but I wanted cubes. The small pieces look better than strands in the finished dish.

Warm or melt your fat of choice over medium heat. I used Earth Balance margarine, but you could also use coconut oil or olive oil.

Add the onions.

Stir to thoroughly coat onions with fat.

After 10 minutes on medium heat. Use a stiff, well-made spatula to scrape up the bits of browning goodness.

After 20 minutes on medium heat.

Scrape scrape. After thirty minutes on medium. I turned it down to medium low.

Forty minutes…

One hour.

What a difference a little time and heat makes! I did not add any salt, sugar, or liquids to enhance the caramelization process.

If you’re making a soup or a pot of beans, at this point you simply add other ingredients and simmer until fully cooked. As I mentioned above, I used fordhook lima beans and simmered them until the broth formed a kind of rich oniony gravy. A perfect dinner!

2 thoughts on “LPTHW: Exercise 3: Numbers and Math and caramelized onions

  1. Pingback: Learning Python: charmed by Coursera | 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 )

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