Operators
Assignment |
|
Arithmetic |
|
Comparison |
|
Logical |
|
String operations (string s)
|
Count occurences |
|
Index of first occurence |
|
Concatenate sequence |
|
Split into list |
List operations (list l, element e)
|
Add e |
|
Remove e |
|
Remove and return e |
|
Count occurences |
|
Reverse l |
|
Sort l |
Dictionary operations (dict d, key k)
|
Clear d |
|
Return d[k] |
|
Return keys in d |
|
Return values in d |
|
Return key-value pairs in d |
|
|
File operations (file f)
|
Open f |
|
Read f |
|
Read line from f |
|
Return list of lines in f |
|
Write s to f |
|
Close f |
In-built functions
int()
, float()
, str()
, bool()
... |
Type casting |
|
Length |
min(values)
, max(values)
|
Minimum / Maximum |
|
X to the power Y [mod Z] |
range(start, stop, [step])
|
Ordered list |
|
Console Input/Output |
filter(function, array)
|
Filter array |
|
Map function onto array |
|
Unique object ID |
|
Round n [x decimal places] |
Module import
|
from module import submodule
|
|
|
Control Flow
if(cond): <code> else: <code>
|
If-else |
if(cond1): <code> elif(cond1): <code> else: <code>
|
If-elif-else |
for i in range([start], stop, [step]): <code>
|
For loop over range |
|
For loop over iterable |
while(condition): <code>
|
While loop |
|
Exit first enclosing loop |
|
Skip to next iteration |
Useful standard library modules
|
Math |
|
Graph plotting |
|
Random generators |
|
Date and time |
|
Performance |
|
Regular expressions |
|
OS interaction |
|
stdin, stdout, stderr, version |
|
Internet access |
|
Data compression |
Object-oriented
|
Class definition |
|
Object creation |
|
Field access |
|
Method access |
|
Created By
Metadata
Favourited By
Comments
dai_xiong, 17:07 16 Apr 18
good
Add a Comment
Related Cheat Sheets