# 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): " ) # we can overwrite what was previously in reply since we don't care about # what was previously in there anymore. we stored the cleaned up version in a different variable, door_sensor print() # clean up the status of the light sensor light_sensor = reply.strip().lower() if ( light_sensor == "off" ) : # this is a nested if statement, since it's an if statement in an if statement print( "Turn on the light" ) # don't need an else, because no action is necessary if the light is already on # Can enter because the door is open and the light is on # print( "Enter room" ) on this indentation level would only execute if the light is off, but we want to # instruct the robot to enter the room regardless of the light status, since if it is off we have already turned # it on print( "Enter room" ) # this needs to be on this indentation level because if the door was locked the robot cannot enter the room # control what indentation level you're on using the tab key ( above caps lock on your keyboard ) # All done # pass v. ... # ... is a value (that you can't do much with) # pass says i want code here, but i don't know what that code is just yet # pass is a no-op -> no operation # it says to just continue on # take the pass statements out and replace it with code, similar to how we've previously used ...