Bird
0
0

Given the following code snippet, what will be the total fine calculated?

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

Given the following code snippet, what will be the total fine calculated?

violation_fine_rates = {'speeding': 100, 'parking': 50}
violations = ['speeding', 'parking', 'speeding']
total_fine = sum(violation_fine_rates[v] for v in violations)
print(total_fine)
A150
B200
C300
D250
Step-by-Step Solution
Solution:
  1. Step 1: Calculate fine for each violation

    Violations are 'speeding', 'parking', 'speeding'. Their fines are 100, 50, and 100 respectively.
  2. Step 2: Sum all fines

    Total fine = 100 + 50 + 100 = 250.
  3. Final Answer:

    250 -> Option D
  4. Quick Check:

    100 + 50 + 100 = 250 [OK]
Quick Trick: Add fines for each violation in the list [OK]
Common Mistakes:
MISTAKES
  • Counting each violation only once
  • Adding fines incorrectly
  • Ignoring repeated violations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes