Python Basics Cheat Sheet

1. Variables and Data Types

Python supports dynamic typing with types like int, float, str, bool, list, tuple, dict, and set. Variables don't need explicit declaration - just assign values directly.

2. Control Flow

Use if/elif/else for conditionals, for and while loops for iteration. Python uses indentation instead of braces to define code blocks.

3. Functions

Define functions with 'def' keyword. Support default parameters, *args for variable arguments, **kwargs for keyword arguments, and lambda for anonymous functions.

4. Data Structures

Lists are mutable ordered collections, tuples are immutable, dictionaries store key-value pairs, and sets contain unique elements. Master list comprehensions for efficient code.

5. Modules and Packages

Import modules with 'import' statement. Use 'from module import function' for specific imports. Create packages by organizing modules in directories with __init__.py files.