# Practical Exercises in Python-100-Days: A Complete Guide to Hands-On Learning

> Explore practical Python exercises in the Python-100-Days repo. Learn with markdown tutorials, runnable scripts, and automated unit tests for hands-on skill development.

- Repository: [骆昊/Python-100-Days](https://github.com/jackfrued/Python-100-Days)
- Tags: how-to-guide
- Published: 2026-02-24

---

**The practical exercises in the `jackfrued/Python-100-Days` repository follow a rigid three-file pattern where each "Day" combines a markdown tutorial, a runnable example script, and a unit-test module for immediate automated feedback.**

The open-source curriculum at `jackfrued/Python-100-Days` teaches Python through progressive, hands-on coding challenges. Rather than passive reading, the practical exercises force learners to implement algorithms, data structures, and applications while verifying their work with automated tests. Each "Day" folder contains self-contained problems that build from basic syntax to advanced web development and machine learning.

## The Three-Component Exercise Architecture

Every practical exercise in the repository is organized into three distinct components that work together to create a complete learning loop.

### Tutorial Documentation

The **tutorial** explains the theory, algorithm steps, or API usage for that day. These are standard markdown files located in day-specific directories, such as `Day31-35/31.Python语言进阶.md` for advanced language features or `Day01-20/07.分支和循环结构实战.md` for branch and loop practice.

### Example Implementation Scripts

Each tutorial links to one or more **example scripts** containing minimal, runnable implementations. These files typically provide a skeleton function or class signature that learners must complete. For instance, [`Day31-35/code/example01.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day31-35/code/example01.py) contains searching algorithms, while [`Day07/prime.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day07/prime.py) contains solutions for the "实战" (practical combat) exercises.

### Automated Test Suites

Every example script is paired with a corresponding **unit-test module** using Python's built-in `unittest` framework. Files like [`Day31-35/code/test_example01.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day31-35/code/test_example01.py) or [`Day07/test_prime.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day07/test_prime.py) import functions from the example scripts and validate them against typical, boundary, and edge-case inputs using `assertEqual` and `assertTrue`.

## How the Practical Exercises Are Structured

The repository follows a consistent pedagogical pattern across all 100 days:

1.  **Problem Statement** – The markdown file introduces a concrete problem (e.g., "实现顺序查找" and "实现二分查找" in the algorithm section).
2.  **Skeleton Code** – The example file provides an empty function signature, encouraging the learner to fill in the logic.
3.  **Manual Verification** – An `if __name__ == '__main__':` block calls a tiny `main()` function that prints sample results for quick sanity checks.
4.  **Automated Validation** – The associated `test_*.py` file confirms correct behavior. Running `python -m unittest` reports success or failure instantly, reinforcing the learning loop.

This workflow repeats from the earliest **"分支和循环结构实战"** (Day 07) to the advanced **algorithmic** challenges (Days 31-35) and **full-stack web** projects (Days 46-60).

## Concrete Examples from the Repository

### Algorithm Practice: Searching and Sorting (Days 31-35)

In the algorithm-focused days, learners implement fundamental computer science concepts. The tutorial in `Day31-35/31.Python语言进阶.md` directs students to implement linear search, binary search, bubble sort, selection sort, merge sort, and quick sort.

The **example implementation** in [`Day31-35/code/example01.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day31-35/code/example01.py) provides the following skeleton functions:

```python
def seq_search(items: list, elem) -> int:
    """顺序查找"""
    for index, item in enumerate(items):
        if elem == item:
            return index
    return -1

def bin_search(items, elem):
    """二分查找"""
    start, end = 0, len(items) - 1
    while start <= end:
        mid = (start + end) // 2
        if elem > items[mid]:
            start = mid + 1
        elif elem < items[mid]:
            end = mid - 1
        else:
            return mid
    return -1

```

The **corresponding test file** at [`Day31-35/code/test_example01.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day31-35/code/test_example01.py) validates these implementations:

```python
class TestExample01(TestCase):
    def setUp(self):
        self.data1 = [35, 97, 12, 68, 55, 73, 81, 40]
        self.data2 = [12, 35, 40, 55, 68, 73, 81, 97]

    def test_seq_search(self):
        self.assertEqual(0, seq_search(self.data1, 35))
        self.assertEqual(-1, seq_search(self.data1, 99))

    def test_bin_search(self):
        self.assertEqual(1, bin_search(self.data2, 35))
        self.assertEqual(-1, bin_search(self.data2, 7))

```

Running `python -m unittest Day31-35/code/test_example01.py` provides immediate pass/fail feedback on the learner's implementation.

### Fundamentals: Branch and Loop Practice (Day 07)

The "实战" (practical combat) tag appears early in the curriculum. The tutorial at `Day01-20/07.分支和循环结构实战.md` describes classic problems like generating prime numbers, calculating Fibonacci sequences, and solving the "百钱百鸡" (hundred coins, hundred chickens) puzzle.

Learners write solutions in standalone scripts such as [`Day07/prime.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day07/prime.py) and [`Day07/fibonacci.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day07/fibonacci.py), each accompanied by a `test_*.py` file that checks correctness for the first few values.

### Web Development and Advanced Topics (Days 46-90)

The practical exercises extend beyond algorithms. **Days 46-60** focus on Django web development, where the exercises involve running [`Day46-60/project/manage.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day46-60/project/manage.py) to start development servers and build complete applications. **Days 81-90** shift to machine learning practice, with exercises stored in files like [`Day81-90/ml_demo.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day81-90/ml_demo.py) that implement ML pipelines.

## Why This Layout Accelerates Learning

The practical exercises in Python-100-Days are designed with specific pedagogical advantages:

- **Isolation** – Each exercise lives in its own folder (e.g., `Day31-35/code/`), preventing name clashes and keeping the learner's focus narrow.
- **Immediate Feedback** – The `unittest` framework provides deterministic pass/fail output without requiring external testing libraries.
- **Progressive Difficulty** – Early days focus on syntax and flow-control; later days introduce data structures, algorithmic complexity, and full-stack development following a natural learning curve.
- **Reference-Ready** – All files are linked directly from the markdown tutorials, allowing learners to jump from description to code with a single click.

## Summary

- The practical exercises follow a **three-file pattern**: markdown tutorial + example script + unit test.
- Learners implement **skeleton functions** in files like [`Day31-35/code/example01.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day31-35/code/example01.py) and verify them with [`test_example01.py`](https://github.com/jackfrued/Python-100-Days/blob/main/test_example01.py).
- The repository covers **progressive topics** from Day 07 (branch/loop basics) to Day 31-35 (algorithms) to Day 46-60 (Django web apps).
- **Automated validation** occurs via `python -m unittest`, providing instant feedback without external dependencies.
- Each day's exercises are **self-contained** in dedicated directories to prevent code conflicts.

## Frequently Asked Questions

### What types of practical exercises are included in Python-100-Days?

The repository includes syntax drills (Day 07), algorithm implementations like searching and sorting (Days 31-35), data structure manipulations, Django web applications (Days 46-60), and machine learning pipelines (Days 81-90). Each type follows the same tutorial-plus-test format.

### How do I run the unit tests for Python-100-Days exercises?

Navigate to the specific day's code directory and execute `python -m unittest test_example01.py` for a single test file, or use `python -m unittest discover -s Day31-35/code` to run all tests in that directory. The built-in `unittest` framework requires no additional installation.

### Are the Python-100-Days exercises suitable for beginners?

Yes. The curriculum starts with fundamental exercises in `Day01-20/07.分支和循环结构实战.md` covering basic control flow, then gradually introduces complexity. Early exercises provide more scaffolding in the example scripts, while later days expect more independent implementation.

### Which file contains the exercise solutions in Python-100-Days?

Complete reference implementations are stored in the [`code/exampleNN.py`](https://github.com/jackfrued/Python-100-Days/blob/main/code/exampleNN.py) files within each Day folder (e.g., [`Day31-35/code/example01.py`](https://github.com/jackfrued/Python-100-Days/blob/main/Day31-35/code/example01.py) for searching algorithms). Learners should attempt to fill in the skeleton code themselves before consulting these files, using the corresponding [`test_exampleNN.py`](https://github.com/jackfrued/Python-100-Days/blob/main/test_exampleNN.py) files to verify their own solutions first.