Bird
0
0
LLDsystem_design~10 mins

Fine calculation 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 calculate the fine amount based on days late.

LLD
fine = [1] * days_late
Drag options to blanks, or click blank then click option'
Adays_late
Btotal_fine
Crate_per_day
Dbase_fine
Attempts:
3 left
💡 Hint
Common Mistakes
Using days_late twice instead of rate_per_day
Using total_fine which is the result, not the rate
2fill in blank
medium

Complete the code to check if a fine should be applied based on days late.

LLD
if [1] > 0:
    apply_fine = True
Drag options to blanks, or click blank then click option'
Adays_late
Btotal_fine
Crate_per_day
Dfine_amount
Attempts:
3 left
💡 Hint
Common Mistakes
Checking fine_amount instead of days_late
Using rate_per_day in the condition
3fill in blank
hard

Fix the error in the code to correctly calculate the total fine with a maximum cap.

LLD
total_fine = min([1] * days_late, max_fine)
Drag options to blanks, or click blank then click option'
Atotal_fine
Brate_per_day
Cmax_fine
Ddays_late
Attempts:
3 left
💡 Hint
Common Mistakes
Using total_fine inside its own calculation
Using max_fine as multiplier instead of cap
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each user to their fine if late.

LLD
user_fines = {user: [1] * days for user, days in late_days.items() if days [2] 0}
Drag options to blanks, or click blank then click option'
Arate_per_day
B>
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality instead of greater than in condition
Using wrong variable for multiplication
5fill in blank
hard

Fill the blanks to filter users with fines above threshold and create a summary dictionary.

LLD
high_fines = {user: fine for user, fine in user_fines.items() if fine [1] threshold}
summary = {
    'count': len(high_fines),
    'max_fine': max(high_fines.values()) if high_fines else 0,
    'average_fine': sum(high_fines.values()) [2] len(high_fines) if high_fines else 0
}
Drag options to blanks, or click blank then click option'
A>
B//
C/
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using integer division '//' instead of '/' for average
Using '+' instead of division for average calculation