Show Menu
Cheatography

Python Cheat Sheet (DRAFT) by

Python

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Variables

Integer
age = 45
Float
rate = 1.5
String
name = "­And­y"
del age (would delete the variable age)

Variables -Syntax

Lower case
Start with letter
Use underscore
No spaces
Strings can use ' ' or " " quotes

Variable Conversion

int(rate)
rate to integer
5.2 to 5
float(age)
age to float
45 to 45.0
str(age)
age to string
45 to "­45"
round(.5425)
Rounds the number
.5425 to 5
Division gives you a float value

Operand

+
Add
-
Subtract
*
Multiply
/
Divide
+=
Add And
Add 5 to age
-=
Subtract And
Subtracts 5 from age
/=
Divide And
Divide by 5
==
Equals
!=
Not Equals
>=
Greater than
Equal to
<=
Less than
Equal to
 

Strings

Must be within matching quotes.
Put double quotes if you have an ' in the sentence
Use "­"­" if you have double quote in sentence
 

Bool

True
 
1
Non Empty
False
0
empty
nothing