I am currently trying to learn how to code. I’m most of the way through a Python tutorial; after that, I plan to take on Django and try my hand at basic web applications.
Coding is not something I am naturally good at. My worst grade in college was in CS 60. Even after two college CS courses and this tutorial now, I still struggle with it. I understand the high-level concepts just fine—my code just doesn’t work. Everything that can go wrong, does—the usual crop of syntax errors, conceptual mistakes, bizarre bugs that even the CS grader-tutors can’t figure out so you end up having to turn in a broken program for half or no credit. If you read Girl Genius, when it comes to programming I feel like Agatha back when her spark’s artificially crippled.
It’s a weird experience for me because I’ve had little difficulty with virtually any other mode of self-expression. I can draw, paint, sculpt, sing, play piano, speak, and write reasonably competently. It’s frustrating to have ideas for web apps in my head and no way to make them real.
At the same time, from a practical standpoint I like working with computer geeks and mastering code seems like a good way to be able to do that. Basic programming knowledge, specifically in Python, is also a requirement of the iSchool master’s program I plan to attend next fall.
So that’s what’s been motivating me to continue hitting my head against this wall.
Anyway, by way of encouragement, a friend pointed me toward this Jeff Atwood post, as well as its update three years later, about how unbelievably many people—many of them CS majors!—apply to programming jobs but don’t know the basics of coding, at all. Thus, many employers have resorted to requiring applicants to solve simple coding programs over the phone or online before they get to the interview stage in order to avoid wasting everyone’s time. One such easy problem is the FizzBuzz test:
After a fair bit of trial and error I’ve discovered that people who struggle to code don’t just struggle on big problems, or even smallish problems (i.e. write a implementation of a linked list). They struggle with tiny problems.So I set out to develop questions that can identify this kind of developer and came up with a class of questions I call “FizzBuzz Questions” named after a game children often play (or are made to play) in schools in the UK. An example of a Fizz-Buzz question is the following:
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes. Want to know something scary? The majority of comp sci graduates can’t. I’ve also seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution.
Sadly (?), even I can solve this one. Does that mean I qualify as a programmer? :P
My solution after the cut.
def fizzbuzz():
for i in range(1, 101):
blah = ''
if i%3 == 0:
blah = blah + 'Fizz'
if i%5 == 0:
blah = blah + 'Buzz'
if blah == '':
blah = blah + str(i)
print blah
(sorry for the extra spaces, I couldn’t get it to reflect the indents properly otherwise)

FizzBuzz!
I’d so end up messing that up if it was in a language I hadn’t used in a while, I’d end up forgetting the syntax for the frontmatter that makes the program actually start or for a for loop or something.
I have taught several introductory programming courses at university, and I wanted to give you one big hint that I found helpful to many of my students:
Spend more time thinking, and less time programming.
Really. Look at the problem, and learn to frame it correctly in your mind. The programming should just be about writing down things you know (and fixing a few syntax errors and finding a few library functions and other manual labour).
The number one error I saw from smart girls (girls in particular, boys tended to go drink beer instead) was that they spent too much time crying into the keyboard and not enough time reasoning away from the keyboard.
Hope that helps. :)