Bird
0
0

What will be the output of this pseudo-code?

medium📝 Analysis Q5 of 15
LLD - Design — Library Management System

What will be the output of this pseudo-code?

fineRates = {"lateReturn": 20, "damage": 100}
violations = ["damage", "lateReturn", "damage"]
totalFine = sum(fineRates[v] for v in violations if v != "lateReturn")
print(totalFine)
A200
B120
C140
D220
Step-by-Step Solution
Solution:
  1. Step 1: Filter violations excluding "lateReturn"

    Violations considered: "damage", "damage"
  2. Step 2: Calculate sum of fines for filtered violations

    Damage fine = 100, two times: 100 + 100 = 200
  3. Final Answer:

    200 -> Option A
  4. Quick Check:

    Sum excluding lateReturn = 200 [OK]
Quick Trick: Filter violations before summing fines [OK]
Common Mistakes:
MISTAKES
  • Including filtered violations
  • Summing all without condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes