File operations
|
open file |
|
read file |
|
read line from file |
|
return list of lines of file |
|
write s to file |
|
close file |
with open(path) as name: statements
|
open and after statements close file |
Logic and Math Operators
|
addition |
|
subtraction |
|
multiplication |
|
division |
|
floor |
|
exponent |
|
modulo |
|
equal |
|
not equal |
|
greater than |
|
greater than or equal |
|
less than |
|
less than or equal |
Converting Data Types
|
number to string |
|
encoded bytes to string |
|
number string to integer |
|
integer to hex string |
|
integer to binary string |
|
float to integer |
|
integer / string to float |
|
string to ASCII |
|
integer to ASCII |
|
|
Base Functions
int(), float(), str(), bool() ...
|
type casting |
|
return length of data |
|
minimum maximum |
|
x to the power y [mod z] |
range(start, stop, [step])
|
range of |
|
console input console output |
filter(function, iterable)
|
filter iterable |
|
unique object ID |
|
map function onto iterable |
|
round n to x decimal places |
Module Import
|
from module import submodule as name
|
Exception Handling
try: statements except [exception type]: statements finally: statements
|
Dictionaries
|
create dictionary |
|
create dictionary with values |
|
assign a value |
|
access value at key |
|
iterable view of keys |
|
iterable view of values |
|
iterable view of (key, value) tuples |
|
clear dictionary |
|
determine if key exists |
Lists
|
create list |
|
assign value at index |
|
access value at index |
|
add to list |
n.insert(position, val)
|
insert into list |
|
count occurness |
|
remove item |
|
remove an return item |
|
reverse n |
|
sort n |
Slicing and Indexing
x[start:stop:step] |
x = [4, 8, 9, 3, 0] |
|
4 |
|
0 |
|
[4, 8, 9] |
|
[3, 0] |
|
[4, 8, 9] |
|
[4, 9, 0] |
|
[0, 3, 9, 8, 4] |
|