Which of the following best explains why handling value is core to blockchain technology?
Think about what blockchain is mostly used for in real life.
Blockchain's main power is to securely move and track digital value like money or assets without needing banks or middlemen.
Consider this Python code simulating a simple blockchain transaction ledger. What will be printed?
ledger = [] # Add initial balance ledger.append({'address': 'Alice', 'balance': 100}) ledger.append({'address': 'Bob', 'balance': 50}) # Alice sends 30 to Bob for entry in ledger: if entry['address'] == 'Alice': entry['balance'] -= 30 elif entry['address'] == 'Bob': entry['balance'] += 30 print(ledger)
Think about how balances change after a transfer.
Alice's balance decreases by 30, Bob's increases by 30, so their balances become 70 and 80 respectively.
What error will this code produce when trying to update balances in a blockchain ledger?
ledger = [{'address': 'Alice', 'balance': 100}, {'address': 'Bob', 'balance': 50}]
for entry in ledger:
if entry['address'] == 'Alice':
entry['balance'] = entry['balance'] - 30
elif entry['address'] == 'Bob':
entry['balance'] += '30'
print(ledger)Look carefully at the types used in the addition operation.
The code tries to add a string '30' to an integer balance, causing a TypeError.
Which of these Python function definitions correctly handles a transaction by deducting from sender and adding to receiver?
Check for correct syntax and logic for transferring value.
Option A correctly updates balances and returns updated accounts. Option A misses return, C uses dot notation on dict, D reverses logic.
Given this code simulating a blockchain ledger with transactions, how many transactions are recorded in the ledger after running?
ledger = [] # Genesis block ledger.append({'block': 0, 'transactions': []}) # Add transactions ledger[0]['transactions'].append({'from': 'Alice', 'to': 'Bob', 'amount': 50}) ledger[0]['transactions'].append({'from': 'Bob', 'to': 'Charlie', 'amount': 20}) # Add new block ledger.append({'block': 1, 'transactions': [{'from': 'Charlie', 'to': 'Alice', 'amount': 10}]})
Count all transactions inside all blocks.
Block 0 has 2 transactions, block 1 has 1 transaction, total 3 transactions.