Building Python Programs is a fully interactive, web-based Python course that enables learners to experiment with Python directly in the browser. It provides a structured curriculum inspired by modern coding environments like VS Code and PyCharm, allowing users to write, execute, and debug Python code seamlessly.
- 📖 Structured Curriculum: Step-by-step units covering everything from basic syntax to advanced concepts.
- 💻 Interactive Python Editor: Powered by Monaco Editor for an enhanced coding experience.
- ⚡ In-Browser Code Execution: Uses Pyodide to run Python code directly in the browser.
- 🖥️ Integrated Terminal: Provides real-time interaction via xterm.js.
- 🎨 Dark/Light Theme Toggle: Persistently saves user preferences.
- 📏 Resizable Lesson & Code Areas: Allows dynamic adjustment using a draggable splitter.
- 🏆 Step-by-Step Challenges: Progressive coding exercises that guide learners through Python basics.
- Frontend Technologies:
- HTML5 Semantic Markup
- CSS3 with Custom Properties & Responsive Layout (Flexbox/Grid)
- Vanilla JavaScript for interactivity and DOM manipulation
- Code Editor & Execution:
- Monaco Editor for editing Python code.
- Pyodide for running Python in the browser.
- Syntax Highlighting:
- Prism.js with custom enhancements for Python.
- Fonts:
building-python-programs/
├── assets/
│ ├── css/
│ │ └── style.css # Main styles, theming, and responsive layout
│ ├── js/
│ │ ├── main.js # Theme and sidebar toggle functionality
│ │ ├── interpreter.js # Python code execution with Pyodide
│ │ ├── splitter.js # Resizable lesson and code area functionality
│ │ ├── challenges.js # Challenge validation logic
│ ├── templates/
│ │ └── unit.html # Template for new course units
├── units/
│ ├── unit-0.html # Unit 0: Getting Started
│ ├── unit-0.json # JSON data for Unit 0 challenges
├── index.html # Homepage integrating lessons and editor
├── README.md # Project documentation
- Clone the Repository:
git clone https://github.com/your-username/building-python-programs.git
- Open in Browser:
cd building-python-programs open index.html # Or double-click index.html
- Navigate to
index.htmlin your browser. - Enter Python code in the Monaco Editor.
- Click Run Code to execute and view results in the integrated terminal.
interpreter.jsinitializes Monaco Editor and xterm.js.- Pyodide executes the Python code in-browser.
- Overrides
input()to work asynchronously with the terminal.
main.jshandles dark/light mode and sidebar collapsing.splitter.jsenables resizable lesson/code areas.
challenges.jsloads JSON-based challenges.- It validates user code execution results dynamically.
Customize the appearance by modifying CSS variables in style.css. For example:
:root {
--rust-accent: #f74c00;
--rust-code-bg: #f5f2f0;
}
[data-theme="dark"] {
--rust-accent: #ff8c00;
--rust-code-bg: #2d2d4d;
}- Create a New Unit:
cp assets/templates/unit.html units/unit-X.html
- Update the Unit:
- Modify the
<title>and header to reflect the new unit's title. - Adjust navigation links in both the new unit and the sidebar.
- Populate the content sections with your lesson materials and code examples.
- Modify the
- Create a JSON File for Challenges:
touch units/unit-X.json
- Add coding exercises in JSON format like
unit-0.json.
- Add coding exercises in JSON format like
Contributions are welcome! To contribute:
- Open an Issue: Describe your proposed changes.
- Fork the Repository.
- Create a Feature Branch:
git checkout -b feature/your-feature-name
- Commit Your Changes:
git commit -m 'Describe your feature or fix' - Push the Branch:
git push origin feature/your-feature-name
- Open a Pull Request describing your changes for review.
This project is distributed under the MIT License. See the LICENSE file for details.
- Prism.js for syntax highlighting.
- Monaco Editor for the interactive code editor.
- Pyodide for running Python in the browser.
- Google Fonts for Fira Sans and Fira Mono typefaces.
- Inspiration from "The Rust Programming Language" book.
