Complete the code to define the initial state of the elevator.
elevator_state = '[1]'
The elevator starts in the IDLE state when it is not moving or opening doors.
Complete the code to transition the elevator state to moving when a request is received.
if request_received: elevator_state = '[1]'
When a request is received, the elevator state changes to MOVING to reach the requested floor.
Fix the error in the state transition when the elevator reaches the floor.
if elevator_state == 'MOVING' and at_floor: elevator_state = '[1]'
When the elevator reaches the floor, it should open the door, so the state changes to DOOR_OPEN.
Fill both blanks to complete the state machine transition for closing doors and going idle.
if elevator_state == 'DOOR_OPEN' and door_closed: elevator_state = '[1]' if elevator_state == '[2]' and no_requests: elevator_state = 'IDLE'
After doors close, elevator moves if there are requests; if no requests, it goes idle.
Fill all three blanks to complete the dictionary for elevator states and their descriptions.
state_descriptions = {
'[1]': 'Elevator is idle and waiting',
'[2]': 'Elevator is moving between floors',
'[3]': 'Elevator doors are open'
}The dictionary maps elevator states to their human-readable descriptions.
