0
0
LLDsystem_design~10 mins

Cancellation and refund policy 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 define the cancellation status in the policy class.

LLD
class CancellationPolicy:
    def __init__(self):
        self.status = '[1]'
Drag options to blanks, or click blank then click option'
Aactive
Bcancelled
Cpending
Drefunded
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'cancelled' as initial status which means policy is inactive.
2fill in blank
medium

Complete the method to check if a refund is allowed based on the policy status.

LLD
def can_refund(self):
    return self.status == '[1]'
Drag options to blanks, or click blank then click option'
Aactive
Bexpired
Ccancelled
Drefunded
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'active' which means policy is still valid.
3fill in blank
hard

Fix the error in the refund calculation method to correctly compute refund amount.

LLD
def calculate_refund(self, amount):
    if self.status == 'cancelled':
        return amount [1] 0.8
    else:
        return 0
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '-' which changes the amount incorrectly.
4fill in blank
hard

Fill both blanks to complete the policy update method that sets status and logs the change.

LLD
def update_policy(self, new_status):
    self.status = [1]
    print('Policy status changed to', [2])
Drag options to blanks, or click blank then click option'
Anew_status
B'new_status'
Cself.status
D'self.status'
Attempts:
3 left
💡 Hint
Common Mistakes
Using string literals instead of variables.
5fill in blank
hard

Fill all three blanks to complete the refund eligibility check with time and status conditions.

LLD
def is_refund_eligible(self, days_since_purchase):
    return self.status == [1] and days_since_purchase [2] [3]
Drag options to blanks, or click blank then click option'
A'cancelled'
B<=
C30
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators or status strings.