Bird
0
0
LLDsystem_design~10 mins

Why parking lot is a classic LLD problem - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the basic entity representing a vehicle in the parking lot system.

LLD
class Vehicle:
    def __init__(self, [1]):
        self.license_plate = license_plate
Drag options to blanks, or click blank then click option'
Alicense_plate
Bparking_fee
Centry_time
Dslot_number
Attempts:
3 left
💡 Hint
Common Mistakes
Using slot number as vehicle identifier
Using parking fee as vehicle attribute
2fill in blank
medium

Complete the code to check if a parking slot is available.

LLD
def is_slot_available(self, [1]):
    return self.slots[slot_id] is None
Drag options to blanks, or click blank then click option'
Alicense_plate
Bentry_time
Cvehicle
Dslot_id
Attempts:
3 left
💡 Hint
Common Mistakes
Passing vehicle instead of slot ID
Using license plate to check slot availability
3fill in blank
hard

Fix the error in the method that assigns a vehicle to a parking slot.

LLD
def park_vehicle(self, vehicle, [1]):
    if self.slots[slot_id] is None:
        self.slots[slot_id] = vehicle
        return True
    return False
Drag options to blanks, or click blank then click option'
Aentry_time
Bslot_number
Cslot_id
Dlicense_plate
Attempts:
3 left
💡 Hint
Common Mistakes
Using slot_number instead of slot_id
Using license_plate as slot key
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps slot IDs to vehicles only if the slot is occupied.

LLD
occupied_slots = { [1]: [2] for [1] in self.slots if self.slots[[1]] is not None }
Drag options to blanks, or click blank then click option'
Aslot_id
Bvehicle
Cslot_number
Dcar
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for key and loop variable
Using slot_number instead of slot_id
5fill in blank
hard

Fill all three blanks to implement a method that calculates total available slots by subtracting occupied slots from total slots.

LLD
def available_slots(self):
    total = len(self.slots)
    occupied = sum(1 for [1] in self.slots if self.slots[[2]] is not None)
    return total - [3]
Drag options to blanks, or click blank then click option'
Aslot_id
Bslot
Coccupied
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for loop and index
Subtracting wrong variable