Bird
0
0

Consider this code:

medium📝 Analysis Q5 of 15
LLD - Design — Hotel Booking System
Consider this code:
slots = {"slot1": True, "slot2": True}
requested = "slot3"
print(slots.get(requested, True))

What will be printed?
AFalse
BNone
CTrue
DKeyError
Step-by-Step Solution
Solution:
  1. Step 1: Check if 'slot3' exists in slots

    'slot3' is not a key in the dictionary.
  2. Step 2: Understand get() with default

    slots.get('slot3', True) returns the default True since key is missing.
  3. Final Answer:

    True -> Option C
  4. Quick Check:

    Missing key returns default True [OK]
Quick Trick: get() returns default if key missing [OK]
Common Mistakes:
  • Expecting KeyError on missing key
  • Confusing default value
  • Thinking None is returned by default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes