Using Comments in VEXcode IQ with Python

Comments are usually added to projects to explain what a programmer wanted parts of the program to do. Comments are helpful when collaborating and troubleshooting, as they document what the code does without having to reread and comprehend many lines of code. Other programmers can read the comments to understand the code's functionality, and the original programmer can remember what their code does after revisiting a project.

Python Comments

A Python comment reads # Example comment. The entire line of code is colored bright green.

All comments in Python start with a # (pound) symbol.

# Library imports
from vex import *

# Begin project code

# Drive in a square
for repeat_value in range(4)
drivetrain.drive_for(FORWARD, 400, MM)
drivetrain.turn_for(RIGHT, 90, DEGREES)

Type any text, numbers, or symbols after the # (pound) sign. Comments typically describe the functionality of the code to help the programmer understand what a piece of code does.

Two lines of Python code are shown. The first line is a comment that reads # Drive forward 500mm. The second line is not a comment, and it reads drivetrain.drive_for(FORWARD, 500, MM).

When the comment is complete, press the "Enter" or "Return" key to go to the next line. Comments only span one line.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: