PythonTheHardWay Flashcards
print “something”
print statement (of something in quotes)
#
pound character used to comment or disable parts of code
+
plus symbol. used to add numbers or concatenate strings
-
minus symbol. used in subtraction
/
slash symbol. used in division
*
asterisk symbol. used in multiplication
%
modulus symbol. used to get remainder in division
less-than symbol.
>
greater-than symbol
less-than-or-equal symbol
> =
greater-than-or-equal symbol
=
single-equal. assigns the value on the right to a variable on the left
==
double-equal. tests if two things have the same value
%s
string formatter
%d
number formatter
%r
raw data formatter. displays the raw data of a variable.
\n
newline symbol
\t
tab symbol
\
escape character
raw_input()
reads a line from input and converts to string
argv
the argument variable. holds the arguments passed into a script from the command line.
import
imports any Python source file as a module
open()
open a file, e.g. txt = open(filename).
read()
read the contents of a file, e.g. txt.read()
close()
close a previously opened file
write()
write to an open file, e.g. f.write(‘some text’)
truncate()
truncate the file size
*args
allows you to pass a non-keyworded variable argument list to a function
seek()
set the position of the read/write pointer within a file
readline()
reads one entire line from the file
not False
True
not True
False
True or False
True
True or True
True
False or True
True
False or False
False
True and False
False
True and True
True
False and True
False
False and False
False
not (True or False)
False
not (True or True)
False
not (False or True)
False
not (False or False)
True
not (True and False)
True