This comprehensive Python study guide covers all essential concepts from basic to advanced levels, designed to help you master Python for your exam and become a proficient Python developer.
Every topic now comes in two formats so you can learn however suits you best:
- π Markdown docs (
.md) β read the concept, syntax, examples, common mistakes, best practices, and exercises. βΆοΈ Python files (.py) β run the live, commented code examples.
New to Python? Set up your development environment first.
- Setup Guides
- Introduction β What Python is and how to use this playground
- Installing Python β Windows, macOS & Linux + verifying the install
- Installing VS Code β Download, install, and tour the editor
- VS Code Extensions β Python, Pylance, Jupyter, Error Lens, and more
- Environment Setup & Tools β Terminal, virtual environments, pip, running code
-
Syntax & Indentation β π docs Β·
βΆοΈ code- Python indentation rules
- Code block structure
- Common indentation errors
-
Data Types & Dynamic Typing β π docs Β·
βΆοΈ code- Built-in data types (int, float, str, bool, list, dict, tuple, set)
- Dynamic typing concepts
- Type checking and conversion
-
Operators β π docs Β·
βΆοΈ code- Arithmetic operators (+, -, *, /, //, %, **)
- Logical operators (and, or, not)
- Comparison operators (==, !=, <, >, <=, >=)
- Membership operators (in, not in)
- Identity operators (is, is not)
-
Control Flow β π docs Β·
βΆοΈ code- if/elif/else statements
- for and while loops
- Loop-else clause (unique Python feature!)
- break and continue statements
-
Functions & Scope β π docs Β·
βΆοΈ code- Function definition and calling
- Parameters vs arguments
- *args and **kwargs
- Local vs global scope
- Lambda functions
-
Lists & Dictionaries β π docs Β·
βΆοΈ code- List operations and methods
- List comprehensions
- Dictionary operations and methods
- Dictionary comprehensions
- Nested structures
-
Strings & Formatting β π docs Β·
βΆοΈ code- String methods and operations
- String formatting (f-strings, .format(), % formatting)
- String validation and manipulation
- Escape characters and raw strings
-
File I/O β π docs Β·
βΆοΈ code- Opening and closing files
- Reading and writing operations
- Context managers (with statement)
- File modes and error handling
-
Packaging & Virtual Environments β π docs Β·
βΆοΈ code- Virtual environments with venv
- Package management with pip
- requirements.txt
- Package structure and distribution
-
PEP 8 & Code Style β π docs Β·
βΆοΈ code- Official Python style guide
- Naming conventions
- Code layout and formatting
- Import organization
- Tools for style checking
-
OOP Fundamentals β π docs Β·
βΆοΈ code- Class definition and instantiation
- Constructor method (init)
- Instance vs class variables
- Instance, class, and static methods
- Object identity and equality
-
OOP Principles β π docs Β·
βΆοΈ code- Inheritance and method overriding
- Encapsulation (public, protected, private)
- Polymorphism
- Multiple inheritance and MRO
- Abstract classes and interfaces
-
Magic Methods β π docs Β·
βΆοΈ code- String representation (str, repr)
- Arithmetic operations (add, sub, etc.)
- Comparison operations (eq, lt, etc.)
- Container operations (len, getitem, etc.)
- Context managers (enter, exit)
-
Generators & Iteration β π docs Β·
βΆοΈ code- Generator functions with yield
- Generator expressions
- Iterator protocol (iter, next)
- Memory efficiency and lazy evaluation
- yield from and generator delegation
-
Regular Expressions β π docs Β·
βΆοΈ code- Pattern matching with re module
- Common regex patterns and metacharacters
- Groups and capturing
- Text validation and extraction
- Practical applications
-
Asynchronous I/O β π docs Β·
βΆοΈ code- async/await syntax
- Event loop and coroutines
- Concurrent vs parallel execution
- Error handling in async code
- Practical async patterns
-
- 20 questions covering data types, operators, control flow, strings, lists, dicts
- Tests included β run and verify your answers
-
- 8 questions covering @property, @classmethod, composition, custom exceptions, encapsulation
- Tests included β run and verify your answers
-
- 10 questions covering inheritance, magic methods, generators, regex, context managers, decorators, async, MRO
- Tests included β run and verify your answers
-
- All roadmap practice questions with solutions
- Comprehensive examples combining multiple concepts
- Real-world applications
Setup β Basic (1-8) β Intermediate (9-11) β Advanced (12-16) β Practice (17)
π Tip: For each topic, read the
.mddoc first to learn the concept, then run the.pyfile to see it in action β and try the exercises at the end of each doc.
- Week 1: Basic concepts (1-4)
- Week 2: Basic concepts (5-8)
- Week 3: Intermediate concepts (9-11)
- Week 4: Advanced concepts (12-16)
- Week 5: Practice questions and review
Each file is executable and contains:
- Concept explanations
- Practical examples
- Common exam patterns
- Key points summary
# Run any concept file
python basic/01_syntax_indentation.py
python intermediate/09_packaging_venv.py
python advanced/13_magic_methods.py
python practice/practice_questions.py- β Python syntax and indentation rules
- β Data types and dynamic typing
- β Control flow (especially loop-else)
- β Functions with *args/**kwargs
- β List and dictionary comprehensions
- β String formatting (f-strings)
- β File I/O with context managers
- β OOP fundamentals (classes, inheritance)
- β Magic methods (str, len, etc.)
- β Generators and yield
- β Regular expressions basics
- β Basic async/await
- Loop-else clause - unique Python feature
- Generator vs list comprehension - memory efficiency
- ***args and **kwargs** - flexible function parameters
- Magic methods - operator overloading
- Context managers - resource management
- Inheritance and MRO - object-oriented design
len(), range(), enumerate(), zip(), map(), filter()
isinstance(), type(), hasattr(), getattr()
min(), max(), sum(), sorted(), reversed()
open(), print(), input(), format()import re # Regular expressions
import os # Operating system interface
import sys # System-specific parameters
import asyncio # Asynchronous I/O
import datetime # Date and time handling
import json # JSON encoder/decoder- Use 4 spaces for indentation
- Lines β€ 79 characters
- snake_case for variables/functions
- PascalCase for classes
- UPPER_SNAKE_CASE for constants
- Practice Coding by Hand - Many exams require writing code without IDE
- Understand Error Messages - Know common exceptions and their causes
- Master List/Dict Comprehensions - Very commonly tested
- Know the Difference - Generator vs list, is vs ==, *args vs **kwargs
- Practice Time Management - Code efficiently under time pressure
Continue your Python journey with:
- Web Development: Django, Flask, FastAPI
- Data Science: NumPy, Pandas, Matplotlib
- Machine Learning: Scikit-learn, TensorFlow, PyTorch
- Automation: Selenium, Beautiful Soup, Requests
- Desktop Apps: Tkinter, PyQt, Kivy
Contributions are welcome! Whether it's fixing a typo, adding a new topic, or improving examples -- check out CONTRIBUTING.md to get started.
Browse open issues or look for good first issue and help wanted labels.
Good luck with your Python exam! πβ¨
Remember: The best way to learn Python is by writing Python code. Practice regularly and don't just read - code along!