Show Menu
Cheatography

Python 2.7 Quick Reference Sheet Cheat Sheet (DRAFT) by

Python Programming Language

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

Operator Precedence Table

func_n­ame­s(args, ...)
Function call
x[inde­x:i­ndex]
Slicing
x[index]
Indexing
x.attr­ibute
Attribute reference
**
Expone­nti­ation
*, /, %
Multiply, divide, mod
+, -
Add, subtract
>, <, <=, >=, !=, ==
Comparison
in, not in
Membership tests
not, and, or
Boolean operators

Module Import

import module­_name
from module­_name import name, ...
from module­_name import *
 

Data Types

TYPE
DESCRI­PTION
EXAMPLE
int
32-bit Integer (unlimited in 3.x)
3, -4
long
unlimited Integer (dropped in 3.x)
101L
float
Floating point number
3.0, -6.55
complex
Complex number
bool
Boolean
True, False
str
Character sequence
"­Imm­utable object­"
str
Character sequence
"­Imm­utable object­"
tuple
Immutable sequence
(2, "­a", [1, 2], (5, 6))
list
Mutable Sequence
[1, [a, b], ("a", "­b")]
dict
Mapping
{x:2, y:5}