This is a draft cheat sheet. It is a work in progress and is not finished yet.
Data Types
str = |
"string", 'string', """multiline string""" |
int = |
1 |
float = |
1.10 |
bool = |
True/False |
list = |
[element1, element2, element3, ...] |
tuple = |
(element1, element2, element3, ...) |
dictionary = |
{key1: value1, key2: value2} |
dictionary[key] = |
value |
# |
line comment |
Operators
== |
equal to |
!= |
not equal to |
< |
less than |
> |
greater than |
<= |
less than or equal to |
>= |
greater than or equal to |
% |
modulo (find the remainder) |
** |
exponent |
+ - * / |
add, subtract, multiply, divide |
| |
union |
& |
intersection |
- ^ |
inclusion relations |
Function
print() |
info you want on the screen |
type() |
find variable type |
int() |
convert variable to integer |
str() |
convert variable to string |
float() |
convert variable to float |
len() |
find variable length |
input() |
request info from user |
|
|
String Methods
(name.upper()) |
all upper case |
(name.lower()) |
all lower case |
(name.capitalize()) |
first letter to upper & all others lower |
(name.title()) |
first letter of each word upper & all others lower |
|