Show Menu
Cheatography

Python Beginner to Advanced Cheat Sheet (DRAFT) by

A detailed Python cheat sheet covering beginner to advanced topics. Python is a popular programming language that can be used on a server to create web applications and this cheat sheet will cover all essential concepts.

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

Basic Syntax

Comments

Single line: Use
#
symbol
Multi-­line: Use triple quotes
"­"­" or ''' 

Inline comments: Add
#
at end of line

Print Function

Basic output:
print()
function displays text
Multiple values: Separate with commas
String format­ting: Use
f-strings, format(), or %
format­ting.

Indent­ation

Critical in Python - Defines code blocks
Use 4 spaces - Standard convention
Consistent indent­ation - All lines in same block must have same indent­ation

Data Types

int
Whole numbers
float
Decimal Numbers
complex
Real + imaginary
str
Character strings
Immutable
Can't change chars
Unicode
Intern­ational support
bool
True/False Values
list
Ordered, mutable
tuple
Ordered, immutable
dict
Key-value pairs
set
Unique elements only
Data types include numeric, text, boolean, and collec­tions.

Formatting

f-strings
f"Hello {name}­"
format()
"­Hello {}".f­or­mat­(name)
% style
"­Hello %s" % name
 

Variable Declar­ation

No keyword needed
Just assign
Dynamic typing
Auto-d­ete­rmined
Case sensitive
myvar ≠ MyVar
Multiple assignment
One line

Naming Rules

Start
Letter or underscore
Characters
alphan­umeric + underscore
No reserved words
if, for, class
Convention
snake_case

Strings (Creation Methods)

Single quotes
'Hello'
Double quotes
"­Hel­lo"
Triple quotes
Multi Line
Raw strings
r'literal'

String Operations

Concat­enation
+
operator
Repetition
* 
operator
Length
len()
function
Indexing
[0] zero-based
Slicing
[start­:en­d:step]

String Methods

Case
upper(), lower(), title()
Search
find(), index(), count()
Check
starts­with(), endswith()
Modify
replace(), strip(), split()