Skip to content

mitjangid/python-by-example

Repository files navigation

Python Quick Overview

A practical, beginner-friendly Python walkthrough created by Amit K. Jangir.

This repository is a compact learning map for Python fundamentals. Each folder focuses on one concept, with small runnable examples and comments written to explain the idea without overwhelming the reader.

Each concept folder also has its own README.md with the files to run, the main ideas to practice, and useful predefined functions or commands for that topic.

What You Will Learn

  • Variables, constants, and basic printing
  • Conditions, if/elif/else, and match statements
  • Collections: lists, tuples, sets, and dictionaries
  • Loops: for loops, while loops, and comprehensions
  • Functions: parameters, return values, lambdas, and closures
  • Classes: OOP, inheritance, and polymorphism
  • Modules and packages
  • Exception handling and custom exceptions
  • File I/O and context managers
  • Decorators and function wrapping
  • Generators and iterators
  • Context managers and resource management
  • Testing with pytest
  • Building APIs with FastAPI
  • Creating web applications with Django

Project Structure

.
|-- 1.variables/          # Variables, types, and basic operations
|-- 2.conditions/         # if/elif/else and match statements
|-- 3.collections/        # lists, tuples, sets, dictionaries
|-- 4.loops/              # for loops, while loops, comprehensions
|-- 5.functions/          # functions, lambdas, closures
|-- 6.classes/            # OOP, inheritance, polymorphism
|-- 7.modules/            # imports, packages, __init__.py
|-- 8.exceptions/         # try/except, custom exceptions
|-- 9.file_io/            # reading/writing files, context managers
|-- 10.decorators/        # function decorators, class decorators
|-- 11.generators/        # generators, yield, iterators
|-- 12.context_managers/  # with statement, custom context managers
|-- 13.testing/           # pytest, fixtures, test cases
|-- 14.fastapi_api/       # REST API with FastAPI and jsonplaceholder
|-- 15.django_trello/     # Task management app with Django
`-- README.md             # This file

How To Run

Install Python 3.10 or newer, then clone the repository and run any sample file directly:

python 1.variables/variables.py
python 2.conditions/conditions.py
python 3.collections/lists.py
python 4.loops/loops.py
python 5.functions/functions.py

For the FastAPI example:

cd 14.fastapi_api
pip install fastapi uvicorn httpx
uvicorn main:app --reload

For the Django example:

cd 15.django_trello
pip install django
python manage.py migrate
python manage.py runserver

For testing:

cd 13.testing
pip install pytest
pytest -v

Recommended Python Version

Use Python 3.10 or newer.

Some examples use modern Python features such as pattern matching (match/case), type hints, and structural pattern matching.

Learning Path

  1. Start with 1.variables/ and 2.conditions/.
  2. Move to 3.collections/, 4.loops/, and 5.functions/.
  3. Learn 6.classes/, 7.modules/, and 8.exceptions/.
  4. Explore 9.file_io/ and 12.context_managers/.
  5. Learn 10.decorators/ and 11.generators/.
  6. Practice 13.testing/ for writing tests.
  7. Build APIs with 14.fastapi_api/.
  8. Create web apps with 15.django_trello/.

Virtual Environments

It's recommended to use virtual environments for Python projects:

# Create a virtual environment
python -m venv venv

# Activate on Windows
venv\Scripts\activate

# Activate on macOS/Linux
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Why This Repository Exists

The goal is to help new Python learners get a quick but useful overview of the language. The examples are intentionally small, readable, and commented so readers can focus on one concept at a time.

Author

Created and maintained by Amit K. Jangir.

If this repository helps you, consider starring it and sharing it with someone starting their Python journey.

About

A practical Python learning repository with well-structured examples covering core concepts, modern features, FastAPI, Django, testing, and real-world programming practices.

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors