Complete the code to define the basic entity representing a vehicle in the parking lot system.
class Vehicle: def __init__(self, [1]): self.license_plate = license_plate
The vehicle is identified by its license plate number, which is essential for tracking.
Complete the code to check if a parking slot is available.
def is_slot_available(self, [1]): return self.slots[slot_id] is None
We check availability by slot ID, not by vehicle or other attributes.
Fix the error in the method that assigns a vehicle to a parking slot.
def park_vehicle(self, vehicle, [1]): if self.slots[slot_id] is None: self.slots[slot_id] = vehicle return True return False
The parameter name must match the key used to access the slot dictionary, which is slot_id.
Fill both blanks to create a dictionary comprehension that maps slot IDs to vehicles only if the slot is occupied.
occupied_slots = { [1]: [2] for [1] in self.slots if self.slots[[1]] is not None }We use slot_id as key and vehicle as value for occupied slots.
Fill all three blanks to implement a method that calculates total available slots by subtracting occupied slots from total slots.
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]
We iterate over slot_id, check occupancy, and subtract occupied count from total.
