This is a draft cheat sheet. It is a work in progress and is not finished yet.
Commets
" " "
This is a comment written
in more than
just one line
" " "
|
Variables
x = 5 |
5 John |
y = "John" |
print(x, y) |
|
Data Types
str |
x = "Hello World" |
int |
x = 20 |
float |
x = 20.5 |
|
|
Strings
a = "Hello, World!" |
e |
print(a[1]) |
!! H = 0 position |
for x in "banana": |
b |
print(x) |
a |
|
n |
|
a |
|
n |
|
a |
a = "Hello, World!" |
13 |
print(len(a)) |
space is included in the len |
txt = "The best things in life are free!" |
print("free" in txt) |
True |
print("free" not in txt) |
False |
b = "Hello, World!" |
llo |
print(b[2:5]) |
|
|
Operators
+ |
x + y |
- |
x - y |
* |
x * y |
/ |
x / y |
% |
3 % 2 = 1 , 7 % 2 = 1 |
** |
3 ** 2 = 3 ^ 2 |
== |
Equal |
!= |
Not equal |
& |
AND |
| |
OR |
|