command pattern def retreat() backward( def quit()screen bye(screen onkey(advance" "screen onkey(turn_left" "screen onkey(turn_right" "screen onkey(retreat" "screen onkey(quit"escape"screen listen(screen mainloop(what you are essentially doing is creating an interface with which to control the turtle in the real worldthis would be akin to remote control car that takes one signal to mean turn leftanother for turn righta third for accelerateand fourth for decelerate if you were to build an rc sender that translated the signals that usually come from the remote to now take input from keyboard using some electronics and your usb portyou would be able to use code similar to the code we have here to control the remote control car in the same wayyou could control robot via remote control in essencewe are sending commands from one part of our system to another the command pattern whenever you want to send an instruction or set of instructions from one object to anotherwhile keeping these objects loosely coupledit is wise to encapsulate everything needed to execute the instructions in some kind of data structure the client that initiates the execution does not have to know anything about the way in which the instruction will be executedall it is required to do is to set up all the required information and hand off whatever needs to happen next to the system since we are dealing with an object-oriented paradigmthe data structure used to encapsulate the instruction will be an object the class of objects used to encapsulate information needed by some other method in order to execute is called command the client object instantiates command containing the method it wishes to executealong