Python. The robot checks the situation


Conditional construction
The robot can use sensors not only in a cyclic design, but also without it. Before each action, the robot can check what the sensors show. 
For this, a conditional construction (if) is used, which allows you to execute commands depending on the condition.
 
if condition:
     commands that are executed if the condition is true (true)
otherwise:
     commands that are executed if the condition is false (false)

If you put the word not (a logical connective meaning negation) before the condition, then the result "true" happens if the condition itself is false.

Complex Conditions
The robot can check several sensors at once. To do this, in the program, you need to link logical commands with bundles:
The and binding requires all the simple logical commands,
and a bunch of or only one of the listed ones.
We are already familiar with the logical link not .


For example 
wall_left or wall_right - this condition is true if there is a wall on at least one of the two specified sides.
wall_left and wall_top - this condition is true if the wall is both left and top at the same time.