Next, translate your pseudocode to Python code. Before inputting drive commands, use print statements for testing, like this one:
direction = input("Please enter a command: ")
if direction == "w":
print("Go forward")
The equal sign may look familiar, but in code it has a slightly different application! The sign is an example of a comparator. Comparators can be used inside conditions to compare values. If the statement is true, the statement below it will execute. These are comparators:
- > Greater Than
- \< Less Than
- >= Greater Than or Equal To
- <= Less Than or Equal To
- == Equal To
- != Not Equal To
Run the cell below and make some changes to the conditionals to see how these work! If you want, you can change the variable names or the input statements. Make sure to test your code.