Final Project Ideas

Published by Brayan K

Turn your new Python skills into real-world projects, paid work, or your own business.

Part of the free Python course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.

Choose a project by the behavior you can demonstrate

A finished small project is more useful than a long list of unimplemented features. Pick one user action, define its input and result, then make the failure cases equally clear. This capstone offers several directions and builds one complete local task-list core so you can see what a reviewable result contains.

Project directionA concrete first acceptance testA failure to handle
Local task listAdd, complete, save and reload the same tasks.Reject a blank title or malformed saved data.
Text analyzerCount words under a documented case and punctuation policy.Explain empty input and undecodable bytes.
Score reportProduce a stable summary from validated records.Keep rejected rows out of the aggregate and report them.
File inventoryInspect a chosen fixture directory without changing its files.Handle a file disappearing between discovery and reading.

Choose extensions only after that first contract works. A graphical interface, web API or database may be useful later, but adding one does not compensate for losing data or accepting invalid records. The reference below uses only the standard library and a temporary workspace.

Build a complete task-list core before adding interactive input

The task contract is deliberately small: each task has a unique positive integer ID, nonempty title and boolean done state. Adding or completing a task returns new normalized data. Saving validates before writing, and loading validates after JSON decoding. The demonstration creates its own file, reloads it and checks the round trip.

import json

def validate_tasks(data):
    if not isinstance(data, list):
        raise ValueError("task storage must be a list")
    ids = set()
    result = []
    for row in data:
        if not isinstance(row, dict) or set(row) != {"id", "title", "done"}:
            raise ValueError("task fields must be id, title and done")
        task_id, title, done = row["id"], row["title"], row["done"]
        if type(task_id) is not int or task_id <= 0 or task_id in ids:
            raise ValueError("task ids must be unique positive integers")
        if not isinstance(title, str) or not title.strip():
            raise ValueError("task title must be nonempty text")
        if type(done) is not bool:
            raise ValueError("task done must be a boolean")
        ids.add(task_id)
        result.append({"id": task_id, "title": title.strip(), "done": done})
    return result

def add_task(tasks, title):
    if not isinstance(title, str) or not title.strip():
        raise ValueError("task title must be nonempty text")
    current = validate_tasks(tasks)
    next_id = max((task["id"] for task in current), default=0) + 1
    return current + [{"id": next_id, "title": title.strip(), "done": False}]

def complete_task(tasks, task_id):
    current = validate_tasks(tasks)
    if type(task_id) is not int or not any(task["id"] == task_id for task in current):
        raise ValueError("unknown task id")
    return [{**task, "done": True} if task["id"] == task_id else task
            for task in current]

def save_tasks(path, tasks):
    payload = json.dumps(validate_tasks(tasks), indent=2, sort_keys=True)
    path.write_text(payload, encoding="utf-8")

def load_tasks(path):
    return validate_tasks(json.loads(path.read_text(encoding="utf-8")))

def render_tasks(tasks):
    rows = sorted(validate_tasks(tasks), key=lambda task: task["id"])
    return "\n".join(
        f'[{ "x" if task["done"] else " " }] {task["id"]} {task["title"]}'
        for task in rows
    )

from pathlib import Path
from tempfile import TemporaryDirectory

tasks = []
tasks = add_task(tasks, "Review the draft")
tasks = add_task(tasks, "Check the examples")
tasks = complete_task(tasks, 1)

with TemporaryDirectory() as directory:
    path = Path(directory) / "tasks.json"
    save_tasks(path, tasks)
    restored = load_tasks(path)
    print(render_tasks(restored))
    print("round trip:", restored == tasks)
    print("open tasks:", sum(not task["done"] for task in restored))

# ✅ Expected output:
# [x] 1 Review the draft
# [ ] 2 Check the examples
# round trip: True
# open tasks: 1

Every function has one boundary: domain operations manage tasks, storage translates between tasks and JSON, and rendering creates text. A command-line adapter can call those functions without moving validation into a prompt loop. Building Command-Line Tools with argparse & Typer owns argument parsing; Working with JSON owns JSON representation.

The file is a real scratch file, not a mocked successful save. This implementation is for one local writer. It does not promise crash-safe replacement, concurrent-writer coordination, access control or a production storage format migration system. Add those only with explicit requirements and tests.

Reject ambiguous or malformed records before they become state

rows = [{"id": 1, "title": "A", "done": False},
        {"id": 1, "title": "B", "done": False}]
ids = [row["id"] for row in rows]
if len(ids) != len(set(ids)):
    raise ValueError("task ids must be unique positive integers")

# ✅ Expected error:
# ValueError: task ids must be unique positive integers

Valid JSON syntax does not establish valid task data. A boolean ID, duplicate ID, missing field or string done flag would violate the application contract. Validate at the load boundary before any command acts on the records. Keep the original file available for diagnosis instead of overwriting malformed input with an empty list.

import json

data = json.loads('{"id": 1, "title": "A", "done": false}')
print(type(data).__name__)
if not isinstance(data, list):
    raise ValueError("task storage must be a list")

# ✅ Expected output:
# dict

# ✅ Expected error:
# ValueError: task storage must be a list

The reference rejects unknown fields too. That is an intentionally strict initial schema, not the only possible compatibility policy. If you later add fields or versioning, specify how old files are recognized and migrated instead of silently discarding their contents.

Keep an invalid operation from changing valid state

import json

def validate_tasks(data):
    if not isinstance(data, list):
        raise ValueError("task storage must be a list")
    ids = set()
    result = []
    for row in data:
        if not isinstance(row, dict) or set(row) != {"id", "title", "done"}:
            raise ValueError("task fields must be id, title and done")
        task_id, title, done = row["id"], row["title"], row["done"]
        if type(task_id) is not int or task_id <= 0 or task_id in ids:
            raise ValueError("task ids must be unique positive integers")
        if not isinstance(title, str) or not title.strip():
            raise ValueError("task title must be nonempty text")
        if type(done) is not bool:
            raise ValueError("task done must be a boolean")
        ids.add(task_id)
        result.append({"id": task_id, "title": title.strip(), "done": done})
    return result

def add_task(tasks, title):
    if not isinstance(title, str) or not title.strip():
        raise ValueError("task title must be nonempty text")
    current = validate_tasks(tasks)
    next_id = max((task["id"] for task in current), default=0) + 1
    return current + [{"id": next_id, "title": title.strip(), "done": False}]

def complete_task(tasks, task_id):
    current = validate_tasks(tasks)
    if type(task_id) is not int or not any(task["id"] == task_id for task in current):
        raise ValueError("unknown task id")
    return [{**task, "done": True} if task["id"] == task_id else task
            for task in current]

def save_tasks(path, tasks):
    payload = json.dumps(validate_tasks(tasks), indent=2, sort_keys=True)
    path.write_text(payload, encoding="utf-8")

def load_tasks(path):
    return validate_tasks(json.loads(path.read_text(encoding="utf-8")))

def render_tasks(tasks):
    rows = sorted(validate_tasks(tasks), key=lambda task: task["id"])
    return "\n".join(
        f'[{ "x" if task["done"] else " " }] {task["id"]} {task["title"]}'
        for task in rows
    )

tasks = add_task([], "Keep this task")
before = [dict(task) for task in tasks]
try:
    add_task(tasks, "   ")
except ValueError as error:
    print(error)
print(tasks == before)
try:
    complete_task(tasks, 99)
except ValueError as error:
    print(error)
print(render_tasks(tasks))

# ✅ Expected output:
# task title must be nonempty text
# True
# unknown task id
# [ ] 1 Keep this task

A failed operation should not half-update the collection. Returning new normalized data makes that contract straightforward in this small program. It does not mean every project must use immutable data, but any mutation-based design still needs a defined failure boundary.

Completing an already completed task remains idempotent: the task stays done. ID generation here is unique within the current stored collection, and the base project does not delete tasks. If a later archive or deletion feature requires IDs never to be reused across history, persist a separate monotonic counter rather than inferring it from remaining tasks.

Test the failure paths that could lose or misrepresent work

import json

def validate_tasks(data):
    if not isinstance(data, list):
        raise ValueError("task storage must be a list")
    ids = set()
    result = []
    for row in data:
        if not isinstance(row, dict) or set(row) != {"id", "title", "done"}:
            raise ValueError("task fields must be id, title and done")
        task_id, title, done = row["id"], row["title"], row["done"]
        if type(task_id) is not int or task_id <= 0 or task_id in ids:
            raise ValueError("task ids must be unique positive integers")
        if not isinstance(title, str) or not title.strip():
            raise ValueError("task title must be nonempty text")
        if type(done) is not bool:
            raise ValueError("task done must be a boolean")
        ids.add(task_id)
        result.append({"id": task_id, "title": title.strip(), "done": done})
    return result

def add_task(tasks, title):
    if not isinstance(title, str) or not title.strip():
        raise ValueError("task title must be nonempty text")
    current = validate_tasks(tasks)
    next_id = max((task["id"] for task in current), default=0) + 1
    return current + [{"id": next_id, "title": title.strip(), "done": False}]

def complete_task(tasks, task_id):
    current = validate_tasks(tasks)
    if type(task_id) is not int or not any(task["id"] == task_id for task in current):
        raise ValueError("unknown task id")
    return [{**task, "done": True} if task["id"] == task_id else task
            for task in current]

def save_tasks(path, tasks):
    payload = json.dumps(validate_tasks(tasks), indent=2, sort_keys=True)
    path.write_text(payload, encoding="utf-8")

def load_tasks(path):
    return validate_tasks(json.loads(path.read_text(encoding="utf-8")))

def render_tasks(tasks):
    rows = sorted(validate_tasks(tasks), key=lambda task: task["id"])
    return "\n".join(
        f'[{ "x" if task["done"] else " " }] {task["id"]} {task["title"]}'
        for task in rows
    )

from pathlib import Path
from tempfile import TemporaryDirectory

tasks = add_task([], "  Check persistence  ")
assert tasks[0]["title"] == "Check persistence"
done = complete_task(tasks, 1)
assert complete_task(done, 1) == done
assert tasks[0]["done"] is False

with TemporaryDirectory() as directory:
    path = Path(directory) / "tasks.json"
    save_tasks(path, done)
    original_file = path.read_text(encoding="utf-8")
    assert load_tasks(path) == done
    invalid = [{"id": True, "title": "bad", "done": False}]
    try:
        save_tasks(path, invalid)
    except ValueError:
        pass
    else:
        raise AssertionError("invalid data was accepted")
    assert path.read_text(encoding="utf-8") == original_file
print("acceptance checks passed")

# ✅ Expected output:
# acceptance checks passed

These checks cover outcomes a user would notice: title normalization, an unchanged original collection, repeat completion, a save/load round trip and rejection before overwriting a good file. They are more informative than a percentage target without examining which behaviors are covered. Testing with pytest: Fixtures, Parametrisation & Mocks owns organizing such checks into a maintained test suite.

A later storage improvement should add a test for interrupted writes before claiming durability. A later user interface should test invalid command arguments and clear error messages. Add checks for the risks introduced by each feature instead of merely repeating the implementation line by line.

Turn the core into a project another person can run

Save the domain and storage functions in a module, keep a small command-line entry point separate, and include a README with the supported Python versions, exact startup command, data location and a short example workflow. Explain what happens to malformed data and how to back up a real task file. Use a virtual environment for dependencies and commit small coherent changes so a failure can be traced.

A useful project review asks you to explain one design choice, one rejected input and one test that caught a defect. A runnable demonstration establishes those specific skills; it does not guarantee a job or prove every production concern is solved. Packaging & Publishing Python Libraries to PyPI owns distributing a package when that becomes part of the project.

Complete the count without changing the task records

Given three task dictionaries, calculate the number still open and the number completed. Fill the two predicates. This is a small reporting addition that should not mutate any task.

tasks = [
    {"id": 1, "title": "A", "done": True},
    {"id": 2, "title": "B", "done": False},
    {"id": 3, "title": "C", "done": False},
]
print(sum(___ for task in tasks))
print(sum(___ for task in tasks))

# 👉 replace ___ with not task["done"]
# 👉 replace ___ with task["done"]

# ✅ Expected output:
# 2
# 1

Add an open-only report and prove the saved tasks are intact

Extend the reference project with an open-only text report. Add three tasks, complete the second, save and reload the complete collection, then display only open tasks in ID order. The filtered display must not delete completed tasks from storage. Check that the reloaded collection still has three tasks and that the completed task remains marked done.

import json

def validate_tasks(data):
    if not isinstance(data, list):
        raise ValueError("task storage must be a list")
    ids = set()
    result = []
    for row in data:
        if not isinstance(row, dict) or set(row) != {"id", "title", "done"}:
            raise ValueError("task fields must be id, title and done")
        task_id, title, done = row["id"], row["title"], row["done"]
        if type(task_id) is not int or task_id <= 0 or task_id in ids:
            raise ValueError("task ids must be unique positive integers")
        if not isinstance(title, str) or not title.strip():
            raise ValueError("task title must be nonempty text")
        if type(done) is not bool:
            raise ValueError("task done must be a boolean")
        ids.add(task_id)
        result.append({"id": task_id, "title": title.strip(), "done": done})
    return result

def add_task(tasks, title):
    if not isinstance(title, str) or not title.strip():
        raise ValueError("task title must be nonempty text")
    current = validate_tasks(tasks)
    next_id = max((task["id"] for task in current), default=0) + 1
    return current + [{"id": next_id, "title": title.strip(), "done": False}]

def complete_task(tasks, task_id):
    current = validate_tasks(tasks)
    if type(task_id) is not int or not any(task["id"] == task_id for task in current):
        raise ValueError("unknown task id")
    return [{**task, "done": True} if task["id"] == task_id else task
            for task in current]

def save_tasks(path, tasks):
    payload = json.dumps(validate_tasks(tasks), indent=2, sort_keys=True)
    path.write_text(payload, encoding="utf-8")

def load_tasks(path):
    return validate_tasks(json.loads(path.read_text(encoding="utf-8")))

def render_tasks(tasks):
    rows = sorted(validate_tasks(tasks), key=lambda task: task["id"])
    return "\n".join(
        f'[{ "x" if task["done"] else " " }] {task["id"]} {task["title"]}'
        for task in rows
    )

from pathlib import Path
from tempfile import TemporaryDirectory

def render_open(tasks):
    validated = validate_tasks(tasks)
    return render_tasks([task for task in validated if not task["done"]])

tasks = []
for title in ["Draft", "Review", "Publish"]:
    tasks = add_task(tasks, title)
tasks = complete_task(tasks, 2)

with TemporaryDirectory() as directory:
    path = Path(directory) / "tasks.json"
    save_tasks(path, tasks)
    restored = load_tasks(path)
    before = [dict(task) for task in restored]
    print(render_open(restored))
    assert restored == before
    assert len(restored) == 3
    assert next(task for task in restored if task["id"] == 2)["done"] is True
    assert load_tasks(path) == restored
    print("stored tasks:", len(restored))

# ✅ Expected output:
# [ ] 1 Draft
# [ ] 3 Publish
# stored tasks: 3

Choose the next extension by its new failure mode

Search adds matching-policy questions; deletion adds identifier-history questions; multiple users add ownership and authorization questions; a web API adds request validation and concurrent writes. Pick one and write its acceptance conditions before implementation. Keep the smallest working version available while the extension is being built.

For a different capstone direction, apply the same review standard to one of the project ideas above: a complete input-to-result path, explicit rejected inputs, durable data where required, a reproducible demonstration and instructions another person can follow. A short working artifact with those properties gives a reviewer more evidence than a feature list.

Practice quiz

What does this program print? tasks = [{"done": True}, {"done": False}, {"done": False}] print(sum(not task["done"] for task in tasks))

  • 2
  • 3
  • 1
  • 0

Answer: 2. Only tasks whose done flag is false contribute to the open count.

Why validate after JSON decoding?

  • Decoding guarantees every domain rule
  • Valid JSON can still have the wrong application shape or values
  • JSON always returns strings
  • Validation is needed only before printing

Answer: Valid JSON can still have the wrong application shape or values. Syntax and schema/domain validity are separate boundaries.

What does this program print? original = [{"id": 1, "done": False}] updated = [{**task, "done": True} for task in original] print(original[0]["done"]) print(updated[0]["done"])

  • True True
  • False False
  • False True
  • True False

Answer: False True. New dictionaries allow the update without changing the original task.

What should an open-only report do to completed tasks in storage?

  • Delete them silently
  • Renumber every remaining task
  • Change done back to False
  • Leave them intact and filter only the displayed view

Answer: Leave them intact and filter only the displayed view. Presentation filtering is not a storage-deletion operation.

What does this program print? ids = [1, 1] print(len(ids) == len(set(ids)))

  • False
  • True
  • 2
  • None

Answer: False. Duplicate identifiers violate the uniqueness check.

Which test provides direct evidence of persistence behavior?

  • Checking only the printed heading
  • Saving and loading the same task collection and comparing it
  • Counting source-code lines
  • Opening an empty file without reading it

Answer: Saving and loading the same task collection and comparing it. A round trip exercises both serialization and loading validation.

What does this program print? tasks = [{"id": 2}, {"id": 1}] print([task["id"] for task in sorted(tasks, key=lambda task: task["id"])])

  • [2, 1]
  • [1]
  • [1, 2]
  • [2]

Answer: [1, 2]. The report explicitly orders tasks by their stable identifiers.

What should happen before claiming concurrent-writer support?

  • Add the claim to the README only
  • Assume a local single-writer demo proves it
  • Increase the number of project features
  • Define coordination behavior and test competing writes and failures

Answer: Define coordination behavior and test competing writes and failures. A new concurrency requirement needs its own design and evidence.

Continue this course

Related lessons