Lesson 19

Hoo-whee, we are really getting into it now, aren’t we! I know this blog is only a week old, but I’ve been working on Learn Python the Hard Way for just shy of two months, and that I’ve gotten through 19 lessons is quite exciting for me! Getting somewhere, even if I am not being assessed – now THERE’S adulthood! Well, maybe it’d be more adult if it wasn’t just so fun!

This exercise deals more with the introduction to writing and using one’s own functions, just like last time.

def cheese_and_crackers(cheese_count, boxes_of_crackers):
print "You have %d cheeses!" % cheese_count
print "You have %d boxes of crackers!" % boxes_of_crackers

We start out by defining cheese_and_crackers, a function that prints out a few statements with the given variables. Just a skosh down the road, we start putting values in for cheese_count and boxes_of_crackers, but suddenly! ack!

amount_of_cheese = 10
amount_of_crackers = 50
cheese_and_crackers(amount_of_cheese, amount_of_crackers)

Now we’re calling cheese_count by the name of amount_of_cheese! WELL. The neat thing here is that in defining the function, we’ve named it something convenient for ourselves, but when we refer to it later, the var should be called something else, to distinguish from the name/s given in the initially defined function. Follow me here:

def function(thing_a, thing_b)
print "here's the %s things and the %s other things" % (thing_a, thing_b)

number_of_things_boop = 20
number_of_things_doop = 30
function(number_of_things_boop, number_of_things_doop)

So that last bit calls the function itself, to which the variables .._boop and .._doop are passed, and since the function initially requires two variables, any two passed in there will then be given the roles of thing_a and thing_b given in the function. Hoo! I have read this paragraph aloud to myself several times, and I think that it makes sense?

So that’s Lesson 19, and it’s also the lesson in which I learned about the html code tag! The explanation is much lengthier than my understanding would have given, but I’m really pleased to have ironed it out so thoroughly, at least for myself. Crystal clear, now!

Code, Coding, Coder

When I was a precocious ten year old, my Dad sat me down with our 486 and showed me the essentials of BASIC, via the inimitable QBASIC, and I wrote HELLO WORLDs and flashing text and extreeemely basic calculators, and I downloaded free games on AOL that were coded in BASIC*.  Later on, I immersed myself in MUDs, or Multi-User Dungeons, the precursor to today’s MMOs, and adored the command line interface, the macros, and that I could play a huge, immersive game with just the keyboard and never have to fiddle with the mouse (with which I have always battled).

Then, despite all predictions, I dropped it!  I tried to take an intro to javascript class in the early 2000s, but something didn’t click (or I was far, far too lazy – take your pick) and it got dropped again.  Over the years, with the advent of the Electronic Frontier Foundation, open-source, linux, and actual, real-life women being represented in tech for the first time, yknow, ever, I’ve gotten excited about structure-level geekery all over again.

For my math qualifications, I was required to take an intro to computer science class, which was taught through Python.  Brilliant!  I excelled at the projects and homework, made friends of the phenomenal and warm instructors, and got my feet wet in Python 3.3.

I continued working on various side projects with 3.3, that is to say, I had no main project at any given point, until I went to OSCON, or the Open Source Convention here in Portland, at its 15-year anniversary convention.  The strength of the movement is greater than ever, and I want to be a part of it.  So I went home, dual-booted Ubuntu, and started Learn Python the Hard Way**.  I nearly named this blog “rachellearnspythonthehardway” or “rachelslpthw” but would eventually like to make this a much broader blog, outlining many of my coding adventures.  I’d like to go through Learn You A Haskell For Great Good! as well, and as a hopeful future math educator, I’ll also be discussing the ways in which I incorporate programming into the high school (or middle school, as employment will have it) classroom.

So let’s begin!

*If anyone knows the guy who made the game Elysian Fields (it’s not the one based on Halo, and it’s not the one made and sold [the one in question was a freeware, hobbyist-made game] in 1984) as well as lots of other BASIC games that he released on AOL in the mid-90s, oh god please contact me.  I’ve stumped Google.  Those games were fantastic.

**I was running python 3.3 on windows and rather than figure out the way to run two versions of python, I installed linux as well so I could re-learn that and not have to fiddle with several versions of python, as Learn Python the Hard Way only teaches in 2.7, for very good reasons that its author, Zed Shaw, has outlined here, toward the bottom.