Skip to content
Activity-based Questions · Q2
Q.

XYZ store plans to give festival discount to its customers. The store management has decided to give discount on the following criteria:

Shopping AmountDiscount Offered
>=500 and <10005%
>=1000 and <20008%
>=200010%

An additional discount of 5% is given to customers who are the members of the store. Create a program using user defined function that accepts the shopping amount as a parameter and calculates discount and net amount payable on the basis of the following conditions:

Net Payable Amount = Total Shopping Amount – Discount.

Punjab PsebTextbookSubjective· 3mImportance★★★★★est
73% · 29/40 Questions
✓ Free question

A user-defined function takes the shopping amount (and membership status), selects the slab rate with an if–elif ladder (5% / 8% / 10%), adds the extra 5% for members, and returns both the discount and the net payable amount = amount − discount.

The idea. Slab-based pricing is a textbook if–elif ladder: test the highest slab first so each amount lands in exactly one band. Packaging it as a function that returns the computed values (rather than printing inside) keeps the calculation reusable, and returning two values uses tuple packing.

def bill(amount, member):
    # Return (discount, net_payable) for a shopping amount.
    # Slabs: >=500 and <1000 -> 5%, >=1000 and <2000 -> 8%, >=2000 -> 10%.
    # Store members get an additional 5%.
    if amount >= 2000:
        rate = 10
    elif amount >= 1000:
        rate = 8
    elif amount >= 500:
        rate = 5
    else:
        rate = 0                      # below 500: no slab discount
    if member == "Y":
        rate += 5                     # additional member discount
    discount = amount * rate / 100
    net = amount - discount
    return discount, net

amt = float(input("Enter total shopping amount: "))
mem = input("Member of the store? (Y/N): ").upper()
disc, net = bill(amt, mem)
print("Discount =", disc)
print("Net payable amount =", net)

Sample runs

Enter total shopping amount: 1500
Member of the store? (Y/N): Y
Discount = 195.0
Net payable amount = 1305.0
Enter total shopping amount: 2500
Member of the store? (Y/N): N
Discount = 250.0
Net payable amount = 2250.0

Checking the arithmetic

AmountSlab rateMember?Total rateDiscountNet payable
15008%Y (+5%)13%195.01305.0
250010%N10%250.02250.0
4500%Y (+5%)5%22.5427.5

(Assumption, stated openly: the extra 5% for members applies on the whole amount and also below the 500 slab, since the problem calls it an additional discount without restricting it. If the store intends members to get it only when a slab applies, move the rate += 5 inside an if rate > 0: guard.)

Watch out

Order the ladder from the highest slab down. Testing amount >= 500 first would trap every large bill in the 5% band, because 2500 also satisfies that condition.

Tip

.upper() on the membership answer makes the program accept y and Y alike — a small robustness habit worth keeping.

✓Final answer

bill() computes: slab discount 5% (500–999), 8% (1000–1999) or 10% (2000+), plus 5% for members, then Net Payable = Amount − Discount; e.g. a member shopping for 1500 gets 13% → discount 195.0 and pays 1305.0.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.