Megan Taylor

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

Learn Python the Hard Way, Exercise 22: What Do You Know So Far?

print outputs results of expressions
python run script using python
# comment out part of a script
+ addition, or concatenate
/ division
* multiplication
% modulo operator
> greater than
< less than
>= greater than or equal to
<= less than or equal to
= equals, names things
%d decimal
%r string
%s string
/n newline
/t tab
\ escape
\\ escape
“”” string, as many lines of text as you want
”’ string, as many lines of text as you want
raw_input read a string from input
pydoc python documentation
open open a file
file open or create a file
os operating system
sys built-in module
import find/initialize a module
argv The list of command line arguments passed to a Python script.
read read a file’s contents
close close a file
readline Read one entire line from the file.
truncate Empties the file
write writes stuff to file
exists Return True if path refers to an existing path. Returns False for broken symbolic links.
def start a function
*args pass an argument list, like argvs for functions
seek set a file’s position
+= delimiter, variable equals itself plus one
return You can return anything that you can put to the right of an =
  • Stijn Debrouwere

    Almost flawless: % is the modulo operator, not percent :-)

    • Yes, thanks, fixed. What does % do in an equation like 3 + 2 + 1 – 5 + 4 % 2 – 1 / 4 + 6 ?

%d bloggers like this: