# A robot encounters a door. If the door is locked, the robot # should be instructed to turn around. If instead the door is # unlocked, the robot should be instructed to open the door and # enter the room. Note, before entering the robot should determine # whether the light is off. If it is off, the robot should be # instructed to first turn on the light. # Get status of the door reply = input( 'Door (locked / unlocked): ' ) # Put in standard format -- all lowercase door_sensor = reply.strip().lower() print() # Based on door sensor take action if ( door_sensor == 'locked' ) : # Cannot enter -- the door is locked print( "Turn around" ) else : # We can go in print( "Open the door" ) # Need to get status of light sensor reply = input( "Light (on / off): " ) light_sensor = reply.strip().lower() # "on"/"off" # We only care about this (the if below) if the door is unlocked (prev # else statement) if ( light_sensor == "off" ): print( "Turn light on" ) print( "Enter room ") # We do this anyways so that's why we # just print this outside the if statement # We want to do this if the light was on and if the light was off, # we first turn light on then enter the room # Can enter because the door is open and the light is on pass # All done