Select Page

Continuing working through Zed’s Learn Python the Hard Way. Zed’s tome continues to be as enjoyable as it is informative…and exercises 11-17 cross a couple of important thresholds for learning a new language: getting information into a program (interacting with it) and working with files. Learning how to do these two things has always brought a significant sense of achievement for me, regardless of the language in question.

Exercise 11: Asking Questions
A simple but fun exercise for introducing and using raw_input and seeing some rudimentary ways users can interact with programs.

Exercise 12: Prompting People
Basically this exercise refactors the previous one to more elegantly use raw_input to prompt and store user input. I’d recommend reading the introduction to the chapter and trying to refactor your previous exercise without copying Zed’s example.

Zed also introduces the reader to pydoc (try “q” if you get stuck).

Exercise 13: Parameters, Unpacking, Variables
Again, kind of surprised at the velocity with which we’re moving. This exercise jumps right in to passing arguments to your program and importing modules.

All in all, an easy chapter…but there is a seriously unfortunate issue with where the page break between 35 & 36 falls. If you’ve been grinding through the exercises typing them up and running them, you might not see the instruction to actually pass arguments when you run the program. Of course, when you try to run this exercise without passing arguments to it, Python is going to gripe.

Exercise 14: Prompting and Passing
This exercise basically synthesises what we’ve learned thus far in regards to taking input as an argument vs. taking via prompts with raw_input.

Cheers to Zed for his nods to Tandy, Zork, and Adventure in this chapter. You’ve dated us both, Zed.

Exercise 15, 16, and 17: First Forays into Files

OK, these three chapters carry their own titles, but really constitute a coherent unit: beginning to work with files in Python. Through the exercise, Zed walks you through reading file contents, writing content to a file, and copying content from one file to another. Along the way he had me laughing with quips like,
Don’t worry if they [programmers] confuse you, it’s normal for a programmer to confuse you with their vast extensive knowledge.