This is a draft cheat sheet. It is a work in progress and is not finished yet.
Variable
Number |
integers / floats |
1 / 1.254 |
Character |
strings / text |
A / "I am a student" |
Boolean |
True / False |
addition / multiplication / exponents
string + string |
combine together |
string + number |
fail |
string * string |
fail |
string ** number |
fail |
string * number |
stringstring...(amount of number) |
Operation
x in s |
True if x is contained in s |
x not in s |
True if x is not contained in s |
s.index(item) |
position in s of item |
s[i] |
ith item in s (0-based) |
len(s) |
length of s |
|
|
Commenting
Single Line Commenting |
# ... |
Multi Line Commenting |
""" ... """ |
Function
str() |
converts value to string |
int() |
converts value to integer |
float() |
converts to decimal point |
len() |
the length of the string |
input() |
receive information from user |
print (name.upper()) |
DEREK HALE |
print (name.lower()) |
derek hale |
print (name.capitalize()) |
Derek hale |
print (name.title()) |
Derek Hale |
|
|
Math Symbol
== |
equal |
!= |
not equal to |
<= |
less than / equal to |
>= |
more than / equal to |
% |
modulo (find the remainder) |
/ |
divide (decimal) |
// |
divide (interger) |
* |
multiply |
** |
to the power of |
Vocabulary
variable |
value and can be changed |
string |
a list of characters (number/letter) |
float number |
number with decimal point |
integer number |
counting number |
modulo |
finding the remainder |
syntax |
grammar/structure of language |
length |
the length of the string |
list |
[ value, ... ] |
|