Jobbed!

just to let y’all know, I have a job! wow! it can actually happen, to go from zero computer knowledge to some (what’s the axiom, “the more I know the more I know I don’t know,” right?) and then BE EMPLOYED is actually possible. seriously, I started with so little. and I have so much more to learn, good god. I want to explore the command line more, as well as security, web frameworks (hello django!), JSON, databases, vim, a different terminal, another linux install, a home server, learn about big people in tech & watch their tutorials & learn, AND maybe even do some tutorials! I don’t know what the tech community NEEDS, but I think it could be handy to find out what kinds of tools are out there to help “level up” from learning Python in whatever essential way most learn it.

Me, I learned Python in IDLE on Windows 7, a program that will get ANYONE up and running in 20 minutes, regardless of operating system. and now I operate nearly everything from the command line in a Linux Ubuntu 12.04 dual-install that I figured out & did myself. I use sublimetext to edit code (and a little bit of nano if it’s something small) and irc to troubleshoot with local coding buddies, and both virtualenv and miniconda to create environments on my machine to play around with. I plan on updating to ubuntu 14.04 in a few days, and the challenge that that will bring.

so! overall message! keep going!!

EOY Recap and 2014 Goals

I love end of year posts, like Scalzi’s and probably others whose blogs I do actually read but can’t think of, ha ha! This has been the year of transferring my nerdiness to generic pop-culture things like reading a ton of scifi and guzzling Star Trek, Doctor Who, Firefly, etc, to some real gritty stuff like some actual facility with computer systems. Very exciting.

I have made a zillion miles of progress and Big Life Decisions this year, and programming-wise, were and are incredibly impactful. My goal that I have been working toward for the last few years has been to teach high school math, I figure I have enough of an aptitude and teenagers are (don’t panic!) actually pretty cool to work with. And I knew I needed to be studying toward something that would get me an actual, adult, non-entry-level job, the contrast to which I worked in for four years, and let me tell you, hearing “well, we think you do deserve a raise, but there’s just no money” is pretty hard to hear/believe when you work for one of the biggest and most successful companies in the world, earning record profits quarter after quarter even in the most difficult of times (see 2009, when I saw coworkers’ 401(k)s slashed to 20-40% of what they had been).

Rant over, getting back to it, part of the coursework for the high school math teaching program at one of the graduate programs I was looking at included an introductory programming course. As I’ve mentioned elsewhere, this really struck me and I joined a ladies’ programming group and stuck with it. After hearing that one definition of a master is 10,000 hours of work put into it, I tried to come up with a figure of how much I’ve put into python and related projects, and I think I’m right around 250h, give or take. So I have a long way to go, but I’m very pleased with having allotted that much over the course of a year. It’s 250 more than I had by last year, and that’s the only metric that’s important right now!

And now, for your handy-dandy list-format of what I’ve started and accomplished this year, under the cut. Wahoo!

Continue reading

Lesson 25

Here we’re getting into writing programs to be used, actually used, on the command line, and that is so exciting. It’s been almost seven months since I made something to actually use, and while I have no real need for a sentence sorter, to have written a program that I can then manipulate in the py shell is REALLY REALLY NEAT, to me.

At first, I struggled a bit with some of the definitions, but I really enjoy separating the definitions from the actual what-you-want-it-to-do-ness of the program, as it were 🙂

Seeing this:
def print_first_word(words):
"""Prints the first word after popping it off."""
word = words.pop(0)
print word

def print_last_word(words):
"""Prints the last word after popping it off."""
word = words.pop(-1)
print word

was pretty exciting, as I recall the idea of “pop”ping from the approximate third of Douglas Hofstadter’s Gödel, Escher, Bach: An Eternal Golden Braid that I read, in one of the interchapter dialogues. Pushing and popping have a very clear analogue in computer science, and while, looking at this particular exercise of Mr Shaw’s, I think that it is not actually the same idea, ha ha! it is still a nice callback even if unintentional and unrelated!

One of the Common Student Questions for this exercise, too, was “what is the difference between print and return, and his answer is somewhat crummy, emphasis mine:

When should I print vs. return in a function?
You need to understand that print is only for printing to the screen and that you can actually do both print and return a value. When you understand this then you'll see that the question is kind of a pointless question. You use print when you want to print. You use return when you want to return.

So I do not really have a clear idea. It seems like once the function has done f(banana) to the stuff, you can either return the result or print it. return seems more verb-y, but the end result seems identical. I will have to read about this!

As a whole this was not a challenging exercise, but it was really fun. I love that Zed Shaw focuses on being able to manipulate python via the structure-level command line rather than via an IDE, like the very popular IDLE which I will not link here. I’ve never imported a function in the shell to play with, and I feel like the possibilities have just expanded. Yeah!

Lesson 21

Moving along, here! This lesson was mostly a refresher on function ordering, for me. At the very end, there is an extra credit portion where he recommends resolving a nested set of functions by hand before running the program.

print "Here is a puzzle."

age = add(30, 5)
height = subtract(78, 4)
weight = multiply(90, 2)
iq = divide(100, 2)

what = add(age, subtract(height, multiply(weight, divide(iq, 2))))

print "That becomes: ", what, "Can you do it by hand?"

I knew that it was necessary to resolve inner parentheses before moving on to the next inner set of parentheses as just a giant composed function, but once I got to the non-commutative operations (ie, subtraction and division, in which order of operation matters) I flubbed it up a bit, and came up with a different answer than when I ran the program. Then I examined it a bit, and with a bit more analysis (that’s an overly heady word for it, ha ha!) in the form of the following:

age = add(30, 5) #35
height = subtract(78, 4) #74
weight = multiply(90, 2) #180
iq = divide(100, 2) #50

and then resolved the commutativity issue, I came up with the same answer that he did! woo-hoo!

Woo-hoo! Another lesson down!

Lesson 20

At first glance, this exercise appeared simple for me, until I got into it a bit. First,

def print_all(f):

That f throws me! I tried to see in the code what it was doing, but I couldn’t, and besides, the point of each lesson is to teach NEW ideas, not expect the student (that’s me!) to understand the language of code intuitively – otherwise, hey, who needs lessons?

So I didn’t understand that right at first, but that’s okay, because further on, we’re given:

print "Let's print three lines:"

current_line = 1
print_a_line(current_line, current_file)

current_line = current_line + 1
print_a_line(current_line, current_file)

current_line = current_line + 1
print_a_line(current_line, current_file)

Hey! Awesome! Given my experience with looping, whether WHILE or IF and maybe some other type I am forgetting right now, I can see a mile away that this can be WAY cleaned up per my specifications! This hugely makes up for the not-knowing of the utility of f previously!

So I go ahead and run the program, something that will print out a text file line by line as well as “rewinding” it, and then I set immediately to cleaning it up:

i = 0
current_line = 1
while i < 3:
print_a_line(current_line, current_file)
current_line += 1
i += 1

Woo-hoo! Nine lines condensed down to six, and while that may not sound like much, a) it can probably be condensed more, and b) it’s a much simpler process, at least for me, to follow. I am thinking I may not even need the i indexing!

Let’s play around, then, a bit. I’m going to take out the i index and make the while loop dependent on current_line rather than on the index.

TOTALLY WORKS, OH YEAH, CHECK IT:


current_line = 1
while current_line <= 3:
print_a_line(current_line, current_file)
current_line += 1

FOUR LINES! So slim!

One last thing: re the f code question from before, well, it was addressed by Mr Shaw in the Common Student Questions portion! The f acts like a VHS-style “read head,” as in, the reading of the file stops at the line you read, and then our defined function rewind moves it back to the position we specify, in this case, the 0th byte, a.k.a. the beginning of the file!

EXERCISE CONQUERED!

EDIT of 13 October 2013: It occurs to me that altering variables is not the best practice for looping. Rather than adding values to current_line, it is a better idea to create an index like i and set current_line equal to the index, and then let the index do all the heavy lifting! Then, if I want to call the variable again, it will be unchanged! Woo-hoo!

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.