Python 3 Beginner's Reference Cheat Sheet: by Via
Python 3 Beginner's Reference Cheat Sheet: by Via
Python 3 Beginner's Reference Cheat Sheet: by Via
In-built functions
Assignment
Arithmetic
+, -, *, /, %
Comparison
Logical
not, and, or
Type casting
continue
len(data)
Length
min(values),
Minimum /
math, numpy,
max(values)
Maximum
scipy
pow(x,y, [z])
X to the power Y
matplotlib
Graph plotting
[mod Z]
random
Random generators
datetime
timeit
Performance
Input/Output
re
Regular expressions
Filter array
os
OS interaction
sys
range(start, stop,
)
Index of first
s.find(substring)
occurence
s.split([delimite
input(), print()
sequence
filter(function,
array)
r])
List operations (list l, element e)
l.append(e)
Add e
l.remove(e)
Remove e
l.pop(e)
l.count(e)
Count occurences
l.reverse()
Reverse l
l.sort()
Sort l
Ordered list
[step])
Concatenate
s.join(sequence)
Console
array)
array
urllib
Internet access
id(object)
Unique object ID
zlib
Data compression
round(n, [x])
Round n [x
decimal places]
class Person:
import module
from module import submodule
Return d[k]
if(cond1): <code>
d.keys()
Return keys in d
elif(cond1): <code>
d.values()
Return values in d
else: <code>
d.items()
for i in range([start],
For loop
over
For loop
Read f
f.readline()
f.readlines()
f.write(s)
Write s to f
f.close()
Close f
x = Person(age,
Object
height)
creation
x.age
Field access
x.birthday()
Method
access
If-else
d.get(k)
f.read()
Class
definition
<code>
Open f
Object-oriented
Module import
Clear d
f = open(path)
version
d.clear()
Math
map(function,
Control Flow
Dictionary operations (dict d, key k)
bool() ...
Count occurences
s.count(substring
If-elif-else
range
over
iterable
while(condition):
While loop
<code>
break
Exit first
enclosing
loop
By paul_benn
Sponsored by CrosswordCheats.com
cheatography.com/paul-benn/
Page 1 of 1.
http://crosswordcheats.com