|
Integer
|
-256, 15
|
|
Float
|
-253.23, 1.253e-10
|
|
String
|
"Hello", 'Goodbye', """Multiline"""
|
|
Boolean
|
True, False
|
|
List
|
[ value, ... ]
|
|
Tuple
|
( value, ... )1
|
|
Dictionary
|
{ key: value, ... }
|
|
Set
|
{ value, value, ... }2
|
|
x + y
|
add
|
x - y
|
subtract
|
|
x * y
|
multiply
|
x / y
|
divide
|
|
x % y
|
modulus
|
x ** y
|
xy
|
|
x< y
|
Less
|
x <= y
|
Less or eq
|
|
x > y
|
Greater
|
x >= y
|
Greater or eq
|
|
x == y
|
Equal
|
x != y
|
Not equal
|
|
not x
|
x and y
|
x or y
|
|
int(expr)
|
Converts expr to integer
|
|
float(expr)
|
Converts expr to float
|
|
str(expr)
|
Converts expr to string
|
|
chr(num)
|
ASCII char num
|
|
len(s)
|
length of s
|
|
s[i]
|
ith item in s (0-based)
|
|
s[start : end]
|
slice of s from start (included) to end (excluded)
|
|
x in s
|
True if x is contained in s
|
|
x not in s
|
True if x is not contained in s
|
|
s + t
|
the concatenation of s with t
|
|
s * n
|
n copies of s concatenated
|
|
sorted(s)
|
a sorted copy of s
|
|
s.index(item)
|
position in s of item
|
|
s.lower()
|
lowercase copy of s
|
|
s.replace(old, new)
|
copy of s with old replaced with new
|
|
s.split( delim )
|
list of substrings delimited by delim
|
|
s.strip()
|
copy of s with whitespace trimmed
|
|
s.upper()
|
uppercase copy of s
|
|
del lst[i]
|
Deletes ith item from lst
|
|
lst.append(e)
|
Appends e to lst
|
|
lst.insert(i, e)
|
Inserts e before ith item in lst
|
|
lst.sort()
|
Sorts lst
|
|
len(d)
|
Number of items in d
|
|
del d[key]
|
Removes key from d
|
|
key in d
|
True if d contains key
|
|
d.keys()
|
Returns a list of keys in d
|
|
sys.argv
|
List of command line arguments (argv[0] is executable)
|
|
os.environ
|
Dictionary of environment variables
|
|
os.curdir
|
String with path of current directory
|
|
exit( code )
|
Terminate program with exit code
|
|
raw_input("prompt")
|
Print prompt and readline() from stdin1
|
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.