0
0
LLDsystem_design~10 mins

Transaction history in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the transaction list.

LLD
class TransactionHistory:
    def __init__(self):
        self.transactions = [1]
Drag options to blanks, or click blank then click option'
ANone
B{}
C[]
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a dictionary {} instead of a list.
Initializing with None or 0.
2fill in blank
medium

Complete the code to add a transaction to the history.

LLD
def add_transaction(self, transaction):
    self.transactions.[1](transaction)
Drag options to blanks, or click blank then click option'
Ainsert
Bappend
Cremove
Dpop
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove or pop which delete items.
Using insert without specifying index.
3fill in blank
hard

Fix the error in the method to get the last transaction.

LLD
def get_last_transaction(self):
    if not self.transactions:
        return None
    return self.transactions[[1]]
Drag options to blanks, or click blank then click option'
A-1
B0
C1
Dlen(self.transactions)
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 returns the first transaction.
Using len(self.transactions) causes index error.
4fill in blank
hard

Fill both blanks to filter transactions by minimum amount.

LLD
def filter_transactions(self, min_amount):
    return [t for t in self.transactions if t.[1] >= [2]]
Drag options to blanks, or click blank then click option'
Aamount
Bmin_amount
Cdate
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing wrong attributes like date or status.
Using wrong variable names.
5fill in blank
hard

Fill all three blanks to create a dictionary of transaction IDs to amounts for completed transactions.

LLD
def get_completed_transactions(self):
    return {t.[1]: t.[2] for t in self.transactions if t.[3] == 'completed'}
Drag options to blanks, or click blank then click option'
Atransaction_id
Bamount
Cstatus
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys or values in the dictionary.
Filtering by wrong attributes.