DAY 21 / 40
>> Module 03 / Day 21 / Lecture

What is a Blockchain?

Module 3 begins — from Python to the chain

You already know Python. Today that knowledge clicks into something bigger — the technology behind Bitcoin, Ethereum, and Polkadot.

Lecture 75 min  ·  09:00–10:15
Lab 60 min  ·  Draw a ledger
Module M3  ·  Blockchain Basics
DAY 21 / 40
>> Today's roadmap

Five steps to understanding the chain

  1. The trust problem — why do we need blockchain at all?
  2. What is a ledger? The record of who owns what
  3. Centralised vs distributed — who holds the ledger?
  4. Key properties: Immutable + Decentralised + Transparent
  5. Lab — represent a ledger as a Python dict
DAY 21 / 40
>> 01 / 04 · The problem

You trust your bank. But should you have to?

When you send money to a friend, your bank updates a spreadsheet: subtract from your account, add to theirs. You never see that spreadsheet. You trust the bank completely.

The problem: What if the bank makes a mistake? Gets hacked? Goes bankrupt? Freezes your account? You have no control over your own money.
DAY 21 / 40
>> 02 / 04 · Ledgers

A ledger is just a list of who owns what

Traditional Ledger

A private spreadsheet inside a bank's server. Only the bank can read and write it. You see only your own transactions.

Blockchain Ledger

A public list of every transaction ever. Thousands of computers hold a copy. Anyone can verify any transaction.

Same idea, different control. Both record "Alice sent 10 to Bob." The difference is who gets to check — and who can change it.
DAY 21 / 40
>> 03 / 04 · Architecture

One copy vs many copies

CENTRALISED

One server holds the truth. Fast and easy to manage. Single point of failure — hack the server, game over.

DISTRIBUTED

Thousands of copies on thousands of machines. No single owner. To change the record you'd need to change ALL copies.

BLOCKCHAIN

A distributed ledger with a special rule: once a record is added, it is mathematically impossible to change it without detection.

Impossible to change? Yes — because every record is sealed by a cryptographic hash. We'll see exactly how in Day 22.
DAY 21 / 40
>> 04 / 04 · Key properties

What makes a blockchain special

IMMUTABLE

Once written, a record cannot be altered. Change one character and the entire chain breaks.

Example: You cannot rewrite a transaction from 2019.

DECENTRALISED

No single company or government owns it. Thousands of independent nodes all hold the same copy.

Example: Bitcoin runs on ~15,000 nodes worldwide.

TRANSPARENT

Every transaction is public. Anyone can open a block explorer and see every transfer ever made.

Note: Anonymity comes from addresses, not hidden data.

DAY 21 / 40
>> Connecting to Python

A ledger is just a Python list of dicts

ledger.py
ledger = [ {"from": "Alice", "to": "Bob", "amount": 10}, {"from": "Bob", "to": "Carol", "amount": 4}, {"from": "Alice", "to": "Carol", "amount": 6}, ] # Total balance for Bob: received = sum(tx["amount"] for tx in ledger if tx["to"] == "Bob") sent = sum(tx["amount"] for tx in ledger if tx["from"] == "Bob") print(f"Bob's balance: {received - sent}") # 6
DAY 21 / 40
>> 11:00 – 12:00 · Lab

Today's lab — Draw the Ledger

CORE "Ledger in Python"

Create a list of 5 transaction dicts. Print all transactions for a specific person (both sent and received). Calculate their balance.

★ STRETCH "Ledger validator"

Add a rule: no one can send more than they have. Check all transactions in order and raise a flag if a balance goes negative.

How to submit. Create students/<username>/D21_ledger.py. Full brief in lab/module_3_blockchain/D21_ledger/problem.md. PR before 12:00.
DAY 21 / 40
>> End of Day 21

What you now understand

  • ✓ Why blockchain exists: the trust problem with centralised ledgers.
  • ✓ What makes it special: immutable, decentralised, transparent.
  • ✓ How it connects to Python: a ledger is a list of transaction dicts.
01 / 9
←/→ navigate   F fullscreen