Skip to content

Repository files navigation

Python - Intermediate Guide

A hands-on, code-first walkthrough of intermediate Python concepts: conditionals, dictionaries, functions, classes, file handling & exceptions, and automated testing, plus bonus material on data visualization and machine learning basics.

Note: This repo assumes you already know Python fundamentals (variables, strings, basic loops, lists). It picks up from there. If you're brand new to Python, work through a beginner resource first (e.g. the early chapters of Python Crash Course), then come back here.

Why this repo

Most "intro to Python" repos stop at syntax. This one is built around the topics that actually trip people up once they're past the basics: nested data structures, writing reusable functions, designing classes, handling real-world I/O failures gracefully, and testing your own code. Each chapter is a folder of small, runnable scripts. Read the code, run it, break it, fix it.

Structure

python/
├── ch. 5  (ifs)                  → conditional logic, nested ifs, boolean tests
├── ch. 6  (Dictionaries)         → dicts, nested dicts, looping over key/value pairs
├── ch. 7                         → loops + dictionaries combined, user input loops
├── ch. 8  (Functions)            → function args/kwargs, return values, importing modules
├── ch. 9  (Classes)              → OOP: classes, inheritance, composition
├── ch. 10 (files&Exceptions)     → reading/writing files, JSON storage, try/except/else
├── ch. 11 (testing)              → unit testing with pytest, fixtures, assertions
└── extras/                       → bonus material, see below

Folders are numbered to match the order topics build on each other — dictionaries before classes, classes before file persistence, file persistence before testing your own modules.

Chapter breakdown

Chapter Topic What's inside
ch. 5 Conditionals if/elif/else chains, comparison & boolean operators, conditional checks against lists
ch. 6 Dictionaries Nested dictionaries, looping with .items()/.keys()/.values(), dictionaries of lists
ch. 7 Loops + Dicts Combining while/for loops with dictionary lookups, simple interactive programs
ch. 8 Functions Positional/keyword/default arguments, *args/**kwargs-style patterns, returning values, importing your own modules
ch. 9 Classes (OOP) Defining classes, __init__, instance methods, inheritance, composing objects (e.g. a Car with a Battery)
ch. 10 Files & Exceptions Reading/writing .txt files, storing data with json, try/except/else, handling FileNotFoundError and ValueError
ch. 11 Testing Writing unit tests with pytest, using fixtures, asserting expected behavior of your own classes/functions

Extras / Bonus

These aren't part of the core sequence above but are included as supplementary exploration:

  • training/ — Misc. practice scripts (palindrome checks, prime numbers, pattern printing, basic data validation) plus early experiments with charts (matplotlib/seaborn-style scatter plots) and a first pass at logistic regression.
  • Linear-regression/ — Notes on what linear regression is and the math behind it, as a primer before/alongside the logistic regression script in training/.

Getting started

git clone https://github.com/<your-username>/<repo-name>.git
cd <repo-name>

Pick a chapter folder and run any script directly:

cd "python/ch. 9 (Classes)"
python car.py

For the testing chapter, you'll need pytest:

pip install pytest
cd "python/ch. 11 (testing)"
pytest

For the chart/regression scripts in training/, you'll need:

pip install matplotlib seaborn pandas scikit-learn

Requirements

  • Python 3.10+
  • pytest (for ch. 11)
  • matplotlib, seaborn, pandas, scikit-learn (for training/ extras only)

Contributing / Using this for your own learning

This started as personal coursework, so code quality varies file to file (that's intentional as it's a learning log, not a polished library). Feel free to fork it, fix bugs, or open a PR if you spot something genuinely wrong. Issues pointing out better idiomatic approaches are welcome.

About

A hands-on, code-first walkthrough of intermediate Python concepts: conditionals, dictionaries, functions, classes, file handling & exceptions, and automated testing, plus bonus material on data visualization and machine learning basics.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages