0
0
LLDsystem_design~10 mins

Pricing strategy (discounts, coupons) 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 apply a fixed discount to the original price.

LLD
final_price = original_price - [1]
Drag options to blanks, or click blank then click option'
Adiscount_amount
Bdiscount_rate
Ccoupon_code
Dtax_amount
Attempts:
3 left
💡 Hint
Common Mistakes
Using discount_rate instead of discount_amount
Subtracting tax_amount instead of discount
2fill in blank
medium

Complete the code to calculate the discount amount from a percentage rate.

LLD
discount_amount = original_price * [1]
Drag options to blanks, or click blank then click option'
Afinal_price
Bcoupon_code
Cdiscount_rate
Dtax_rate
Attempts:
3 left
💡 Hint
Common Mistakes
Using coupon_code instead of discount_rate
Multiplying by tax_rate by mistake
3fill in blank
hard

Fix the error in the code to apply a coupon discount only if the coupon is valid.

LLD
if coupon.is_valid():
    final_price = original_price - [1]
Drag options to blanks, or click blank then click option'
Acoupon.discount_amount
Btax_amount
Cdiscount_rate
Dcoupon_code
Attempts:
3 left
💡 Hint
Common Mistakes
Using coupon_code string instead of discount_amount
Subtracting tax_amount by mistake
4fill in blank
hard

Fill both blanks to calculate the final price after applying a percentage discount and adding tax.

LLD
discount_amount = original_price * [1]
final_price = (original_price - discount_amount) * (1 + [2])
Drag options to blanks, or click blank then click option'
Adiscount_rate
Btax_rate
Cdiscount_amount
Dcoupon_code
Attempts:
3 left
💡 Hint
Common Mistakes
Using coupon_code instead of discount_rate
Adding tax before subtracting discount
5fill in blank
hard

Fill all three blanks to create a dictionary of coupons with their discount rates, filtering only those above 10%.

LLD
coupons = {code: [1] for code, [2] in all_coupons.items() if [3] > 0.1}
Drag options to blanks, or click blank then click option'
Adiscount_rate
Dcoupon_code
Attempts:
3 left
💡 Hint
Common Mistakes
Using coupon_code as value
Filtering by code instead of discount_rate