# 🐍 Python 3D Academy

A personal web app for learning Python from zero, chapter by chapter, in **English and বাংলা**.
Every lesson has a 3D animation, examples you can run, a quiz and auto-checked tasks.
Each chapter ends with a treasure chest of LeetCode suggestions.

Python runs **inside your browser** (Pyodide), so there is no server and no account.
Your progress is saved in the browser; use **Settings → Export progress** to keep a backup file.

## Run it

```bash
npm install
npm run dev        # open the printed http://localhost:5173
```

For a production build that works offline once loaded:

```bash
npm run build
npm run preview
```

## Check it

```bash
npm test           # unit, component and content tests (the content checker runs real Python)
npm run typecheck
npm run e2e        # builds, then runs the lesson-1 smoke test in headless Chromium
```

## Add or edit lessons

Lessons live in `src/content/chapters/chNN/lesson-NN.ts`. Every text is `{ en, bn }`.
A lesson has `sections` (text, animation, example), a `quiz` of 4–6 questions and 2–3 `tasks`.

A task's tests are either:
- `{ expectedOutput: "..." }`, which compares what the program prints, or
- `{ expr: "x", expected: "5" }`, which evaluates a Python expression after the code runs.

Either kind can also set `stdin`.

Run `npm test` after editing. `tests/content.test.ts` runs every example, quiz answer and task solution in real Python. It fails with a message naming the lesson if anything is wrong, including a missing Bangla text.

When a task can be solved in more than one way, add the other ways to `tests/alternatives.test.ts`. They must pass the task's tests too, so learners aren't marked wrong for a correct answer.

Lesson code that contains a backslash (such as `"\n"`) must be written with `` String.raw`...` ``. Otherwise JavaScript turns `\n` into a real new line before Python sees it.

New animations go in `src/animations/scenes/<name>/`. Each scene has a `spec.ts` (props and captions) and a component file (3D scene + 2D fallback). Register it in `specs.ts` and `registry.ts`. If a scene's captions state a Python result (like "7 // 3 is 2"), give its spec a `checks()` list. The content checker runs each check in real Python.

## Known limits

- Browser Python can't run threads, multiple processes or internet requests. Lessons on those topics explain and animate the idea instead.
- The Bangla text was written with AI help and has not yet been reviewed by a native teacher. If a sentence reads oddly, edit the lesson file.
- Clearing your browser's site data deletes your progress. Export a backup first.
