A python example of how to design and implement a state machine for a certain task.