Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Crash Course

Beginner Python for people who want to be ready for machine learning libraries next — not a NumPy/pandas/scikit-learn course yet.

Course quality Open in Colab

Start here: notebooks/00_Colab_and_First_Program.ipynb · Open in Colab

Track progress: GitHub Pages dashboard (self-tracked in your browser)

Who this is for

  • You can use a browser. You do not need Python installed locally.
  • You want a stepped path: Colab → values → collections → control flow → functions → files → data preparation.
  • After the capstone you should be ready to open a NumPy or pandas tutorial without fighting basic Python.
  • This course teaches the Python that pandas and scikit-learn assume you already know: tidy rows, missing vs 0, strip, dates, numeric X, train-only stats.

Skills pandas and sklearn assume first

Those libraries will not teach this. Each skill below is practiced in pure Python, then named in the library you will meet next.

You learn here Notebook You will type later
strip / replace / join 01 s.str.strip(), s.str.replace()
is None, not == None 01 isna() — and never df == np.nan
dict in, .get, .items() 02 column lookup; df.items()
sorted(xs) vs xs.sort() 02 df.sort_values() returns a new frame
dict counts, any / all, missing vs 0 03 value_counts(), isna().any(), df[mask]
help / .__doc__, copy don't mutate 04 help(pd.read_csv), Copy-on-Write
JSON/CSV, datetime, NaN / isclose 05 read_csv, to_datetime, isna()
Split first, train-only scale, codes, X as numbers 06 train_test_split, MinMaxScaler, OneHotEncoder
Dirty CSV → checked train/valid bundle 07 A pandas Pipeline does the same verbs

Skip for now: NumPy, pandas, scikit-learn, regex, class inheritance, input().

How to take the course

  1. Work in Google Colab. Click a badge, then File → Save a copy in Drive.
  2. Run each notebook from the top. If the runtime gets confused, Runtime → Restart session and Run all.
  3. Practice cells already contain working answers so the notebook can be verified. To practice, delete the answer, rewrite it, and run the check.
  4. Optional: fork this repository and enable the Pages dashboard so your copy has its own progress page.

There is no input() in the maintained notebooks, so they never wait for a prompt.

flowchart LR
  startNode["Open notebook 00        "] --> copyDrive["Save a copy in Drive        "]
  copyDrive --> runTop["Run cells top to bottom        "]
  runTop --> rewrite["Rewrite the practice cells        "]
  rewrite --> nextNb["Open the next notebook        "]
  nextNb --> optionalDash["Optional: tick progress on Pages        "]
Loading

Course path

# Notebook Time What you learn Colab
00 Colab and your first program 40 min Runtime, print, variables, +=, unpacking, indentation, reading errors Open
01 Values, strings, and conversion 55 min Types, / // %, strip/replace/join, is None, converting CSV-like strings, f-strings Open
02 Collections, indexing, and slicing 60 min Lists, tuples, dicts, sets, in on keys, .get/.items(), sorted vs .sort(), copies Open
03 Conditionals and loops 60 min if/elif, loops, dict counts, any/all, missing vs 0 Open
04 Functions, scope, and comprehensions 55 min def, returns, docstrings/help, copy-not-mutate, list/dict comprehensions Open
05 Errors, modules, and files 60 min Errors, pathlib, JSON, CSV, datetime, NaN / isclose Open
06 Python data workflows for ML 65 min Clean rows, codes and one-hot, table shapes, split first, train-only scaling Open
07 Fundamentals capstone 60 min Prepare a dirty bike-share CSV end to end — no model yet Open

About seven to eight hours if you do the practices instead of only reading.

flowchart TB
  subgraph pythonBasics ["Python basics        "]
    n00["00 Colab        "]
    n01["01 Values        "]
    n02["02 Collections        "]
    n03["03 Conditionals        "]
    n04["04 Functions        "]
    n05["05 Files        "]
  end
  subgraph mlReady ["Ready for ML libraries        "]
    n06["06 Data workflows        "]
    n07["07 Capstone        "]
  end
  n00 --> n01 --> n02 --> n03 --> n04 --> n05 --> n06 --> n07
Loading

Exercises, hints, and solutions

Each notebook repeats a short cycle: explain → predict → run → practice → check.

Concept sections in each notebook include Mermaid diagrams of the idea (runtime, types, aliases, splits, and so on). They show as pictures in Colab and as Mermaid on GitHub.

flowchart LR
  explain["Explain        "] --> predict["Predict        "]
  predict --> runCell["Run        "]
  runCell --> practice["Practice        "]
  practice --> check["Check        "]
Loading
  • Predict questions ask you to decide the output before you run. Answers sit under After you run.
  • Practice cells include a working answer so Run all never fails. Comment it out, rewrite it, then run the check.
  • Checks are assert statements that print Practice xx.y passed.
  • Hints sit under each practice. Solutions and a short Check your understanding section are at the end.

Capstone

Notebook 07 prepares a dirty bike-share CSV in pure Python: parse, type, drop missing/invalid/duplicate rows, derive features, split 80/20 by id, min-max scale using training rows only, then export a JSON bundle. You do not train a model.

You are done when every capstone check prints passed.

flowchart TB
  rawCsv["Dirty bike-share CSV        "] --> parseRows["Parse to dictionaries        "]
  parseRows --> dropBad["Drop missing, invalid, and duplicate rows        "]
  dropBad --> derive["Derive km_per_hour and age_group        "]
  derive --> splitData["Sort by id and split 80/20        "]
  splitData --> trainRows["Train rows        "]
  splitData --> validRows["Validation rows        "]
  trainRows --> fitScale["Fit min-max on train only        "]
  fitScale --> scaleTrain["Scale train        "]
  fitScale --> scaleValid["Scale validation        "]
  scaleTrain --> bundle["Export JSON bundle        "]
  scaleValid --> bundle
Loading

Fork this course and enable the dashboard

Progress is self-tracked in localStorage. GitHub Actions does not grade your Colab work. The quality workflow only checks that the maintained notebooks still run.

On your fork:

  1. Enable Actions if GitHub asks (the first Actions tab visit).
  2. Open Settings → Pages.
  3. Set Source to GitHub Actions. This has to exist before the deploy workflow can publish; the first run fails with Get Pages site failed until it is on.
  4. Run Deploy course dashboard from the Actions tab, or push a change under site/.
  5. Open https://<your-username>.github.io/python-crash-course/.

The dashboard writes Colab links for your owner/repo/branch. Export JSON if you switch browsers. Reset stays on that device.

flowchart TB
  forkRepo["Fork the repository&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"] --> enableActions["Enable Actions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
  enableActions --> enablePages["Settings: Pages source is GitHub Actions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
  enablePages --> deployDash["Run Deploy course dashboard&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
  deployDash --> yourSite["github.io dashboard for your fork&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
  yourSite --> yourColab["Colab links open notebooks on your fork&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
Loading

What to learn next

After this course:

  • NumPy arrays
  • pandas DataFrames (dropna, to_datetime, boolean masks)
  • a plotting library (Matplotlib or Seaborn)
  • scikit-learn Pipeline, train_test_split, and random_state

The verbs stay the same: clean, split, scale, encode, check.

How this repository is organized

flowchart LR
  readme["README&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"] --> notebooks["notebooks/ current course&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
  readme --> site["site/ Pages dashboard&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
  readme --> workflows["GitHub Actions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
  readme --> legacy["legacy/ archived classroom files&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
  workflows --> quality["course-quality&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
  workflows --> pagesDeploy["deploy-pages&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
Loading

Maintained materials are notebooks/ and site/. CI executes only the numbered notebooks. Historical files stay in legacy/ and are not part of the path above.

Legacy classroom archive

Older live-session notebooks and scripts live in legacy/. They are unmaintained and are not part of the numbered path. Several of them do not run top-to-bottom; that is expected.

Author

Ali Mustufa — iali.dev · @ialimustufa

About

Python Crash Course

Resources

Stars

167 stars

Watchers

39 watching

Forks

Releases

Packages

Contributors

Languages