Python Quick Reference
Comprehensive Python reference covering syntax, built-in functions, data structures, and common programming patterns. Perfect for quick lookups during development.
Getting Started
This reference assumes basic programming knowledge. Examples use Python 3.8+ syntax. Run code examples in the Python REPL, Jupyter, or your favorite IDE.
Basic Syntax
Python fundamentals including variables, data types, and basic operations.
Variables & Data Types
Variable Assignment
Basic Data Types
Type Checking & Conversion
Operators
Arithmetic Operators
Comparison & Logical Operators
Control Flow
Control structures for making decisions and repeating operations.
Conditionals
If Statements
Ternary Operator
Loops
For Loops
While Loops
Loop Control
Data Structures
Python's built-in data structures for organizing and manipulating data efficiently.
Lists
List Creation & Access
List Methods
List Slicing
Dictionaries
Dictionary Creation & Access
Dictionary Methods
Sets & Tuples
Sets (Unique Collections)
Tuples (Immutable Sequences)
Functions
Organize code into reusable blocks with parameters, return values, and advanced features.
Function Basics
Function Definition
Function Arguments
Advanced Functions
Lambda Functions
Decorators
Generators
Classes & OOP
Object-oriented programming with classes, inheritance, and special methods.
Class Basics
Class Definition
Special Methods
Inheritance
Basic Inheritance
Modules & Packages
Importing Modules
File I/O
Reading and Writing Files
Error Handling
Try-Except Blocks
Raising Exceptions
Built-in Functions
Essential Built-ins
Input/Output & Inspection
Common Libraries
Standard Library Highlights
Popular Third-Party Libraries
Install third-party libraries using pip: `pip install requests pandas numpy matplotlib`
🐍 Python Best Practices
- • Follow PEP 8 style guide for consistent code formatting
- • Use descriptive variable and function names
- • Write docstrings for functions and classes
- • Handle exceptions appropriately with try-except blocks
- • Use list comprehensions for simple transformations
- • Prefer `with` statements for file operations
- • Use virtual environments for project dependencies
🚀 Keep Practicing
This cheatsheet covers Python fundamentals and common patterns. Practice these concepts by building small projects and solving coding challenges. The more you code, the more natural these patterns will become.