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.
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.
A private spreadsheet inside a bank's server. Only the bank can read and write it. You see only your own transactions.
A public list of every transaction ever. Thousands of computers hold a copy. Anyone can verify any transaction.
One server holds the truth. Fast and easy to manage. Single point of failure — hack the server, game over.
Thousands of copies on thousands of machines. No single owner. To change the record you'd need to change ALL copies.
A distributed ledger with a special rule: once a record is added, it is mathematically impossible to change it without detection.
Once written, a record cannot be altered. Change one character and the entire chain breaks.
Example: You cannot rewrite a transaction from 2019.
No single company or government owns it. Thousands of independent nodes all hold the same copy.
Example: Bitcoin runs on ~15,000 nodes worldwide.
Every transaction is public. Anyone can open a block explorer and see every transfer ever made.
Note: Anonymity comes from addresses, not hidden data.
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}") # 6Create a list of 5 transaction dicts. Print all transactions for a specific person (both sent and received). Calculate their balance.
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.
students/<username>/D21_ledger.py. Full brief in lab/module_3_blockchain/D21_ledger/problem.md. PR before 12:00.