import random
import time
NUM_PARKING_SPOTS = 10
# Initialize parking lot with False (vacant)
parking_lot = [False] * NUM_PARKING_SPOTS
def read_sensor(spot):
"""Simulate reading the status of the parking spot."""
return parking_lot[spot]
def update_parking_lot():
"""Simulate the real-time update of parking lot status."""
global parking_lot
for i in range(NUM_PARKING_SPOTS):
parking_lot[i] = random.choice([True, False])
def display_parking_lot():
"""Display the current parking lot status."""
print("Parking Lot Status:")
for i in range(NUM_PARKING_SPOTS):
status = "Occupied" if parking_lot[i] else "Vacant"
print(f"Spot {i + 1}: {status}")
print()
def find_vacant_spots():
"""Find all vacant spots in the parking lot."""
vacant_spots = []
for i in range(NUM_PARKING_SPOTS):
if not parking_lot[i]:
vacant_spots.append(i + 1)
return vacant_spots
def main():
"""Main function to simulate the smart parking system."""
print("Welcome to Smart Parking Service!")
while True:
update_parking_lot()
display_parking_lot()
vacant_spots = find_vacant_spots()
if vacant_spots:
spots_str = ', '.join(str(spot) for spot in vacant_spots)
print(f"Vacant spots: {spots_str}. You can park here!")
else:
print("Sorry, no vacant spots available.")
time.sleep(5)
if __name__ == "__main__":
main()