Megan Taylor

front-end dev, volunteacher, news & data junkie, bibliophile, Flyers fan, sci-fi geek and kitteh servant

Learn Python the Hard Way

These are thoughts and notes to myself while working through Zed Shaw’s book, “Learning Python the Hard Way.”

Ex1: Don’t over think the extra credit. Use # to comment out lines. This prevents the script from running the line.

Ex3: Order of operations: PEMDAS. Floating point: just add .0 to all integers. Don’t get all bogged down in the binary crap.

Ex4: I repeat: Don’t get all bogged down in the binary floating point crap.

Ex5: Format characters

Ex6: Strings concatenate ( + )

Ex7, 8, 9: Boring, but do it anyway.

Ex10: Escape sequences: new line character (\n), tab (\t), \, \\, “””, more

Ex11: raw_input

Ex12: pydoc, open, file, os, and sys

Ex13: import, argv, modules

Ex15: file, read(), open, close()

Ex16: readline, truncate, write()

Ex17: output.close(), more file stuff

Ex18: functions, checklists
Did you start your function definition with def?
Does your function name have only characters and _ (underscore) characters?
Did you put an open parenthesis ( right after the function name?
Did you put your arguments after the parenthesis ( separated by commas?
Did you make each argument unique (meaning no duplicated names).
Did you put a close parenthesis and a colon ): after the arguments?
Did you indent all lines of code you want in the function 4 spaces? No more, no less.
Did you “end” your function by going back to writing with no indent (dedenting we call it)?

And when you run (aka “use” or “call”) a function, check these things:

Did you call/use/run this function by typing its name?
Did you put ( character after the name to run it?
Did you put the values you want into the parenthesis separated by commas?
Did you end the function call with a ) character.

Ex19: seek, += (delimiters)

Ex21: OMG, I just did math! And it made sense! 35 + 74 – 180 * 50 / 2

Ex22: What Do You Know So Far?

June 3, 2011 | Comments Off on Learn Python the Hard Way | Categories: Posts | Permalink

Comments are closed.

%d bloggers like this: