LLD - Design — Hotel Booking SystemWhich of the following is the correct syntax to check if a key 'slot1' exists in a Python dictionary named availability?Aif availability.contains('slot1'):Bif availability.has_key('slot1'):Cif availability.exists('slot1'):Dif 'slot1' in availability:Check Answer
Step-by-Step SolutionSolution:Step 1: Recall Python dictionary key existence syntaxIn Python 3.x, the correct way to check if a key exists is using the 'in' keyword.Step 2: Analyze optionsif 'slot1' in availability: uses 'in' correctly; 'has_key' was removed in Python 3; 'contains' and 'exists' are invalid methods.Final Answer:if 'slot1' in availability: -> Option DQuick Check:Python dict key check uses 'in' keyword [OK]Quick Trick: Use 'in' keyword to check dict keys in Python 3+ [OK]Common Mistakes:MISTAKESUsing has_key() in Python 3Using non-existent methods like contains()Confusing syntax with other languages
Master "Design — Hotel Booking System" in LLD9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepArchTryChallengeDesignRecallScale
More LLD Quizzes Advanced LLD Concepts - Event-driven design - Quiz 3easy Advanced LLD Concepts - Dependency injection framework - Quiz 9hard Design — Chess Game - Board and piece hierarchy - Quiz 14medium Design — Hotel Booking System - Hotel, Room, Booking classes - Quiz 11easy Design — Hotel Booking System - Cancellation and refund policy - Quiz 15hard Design — Online Shopping Cart - Payment strategy pattern - Quiz 13medium Design — Splitwise (Expense Sharing) - Simplify debts algorithm - Quiz 2easy Design — Splitwise (Expense Sharing) - User, Group, Expense classes - Quiz 4medium Design — Splitwise (Expense Sharing) - Transaction history - Quiz 11easy Design — Splitwise (Expense Sharing) - Transaction history - Quiz 15hard