Show Menu
Cheatography

Python : Cheat Sheet Cheat Sheet (DRAFT) by

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 studen­t"
Boolean
True / False

addition / multip­lic­ation / exponents

string + string
combine together
string + number
fail
string * string
fail
string ** number
fail
string * number
string­str­ing...(­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.inde­x(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 inform­ation from user
print (name.u­pp­er())
DEREK HALE
print (name.l­ow­er())
derek hale
print (name.c­ap­ita­lize())
Derek hale
print (name.t­it­le())
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 (numbe­r/l­etter)
float number
number with decimal point
integer number
counting number
modulo
finding the remainder
syntax
gramma­r/s­tru­cture of language
length
the length of the string
list
[ value, ... ]