Which symbol is used for comments in Python?

A. //
B. /*
C. #
D. --
Correct Answer: C. #

In programming, comments are non-executable lines of code that developers include to make their code more understandable for themselves and others. They are ignored by the interpreter or compiler. Different programming languages use different symbols to denote comments.

For Python, the symbol used for single-line comments is the hash symbol.

The correct answer is C: #. In Python, any text following a '#' on a line is considered a comment and is not executed.

A: // is incorrect; this symbol is commonly used for single-line comments in languages like C++, Java, JavaScript, and C#. B: /* is incorrect; this symbol, typically paired with '*/', is used for multi-line comments in languages such as C, C++, Java, and JavaScript. D: -- is incorrect; this symbol is used for comments in languages like SQL and Ada, among others, but not Python.

Leave a Comment

Scroll to Top