Which symbol is used for multi-line comments in Python?

Master Python with the PCAP Certification! Explore interactive quizzes and detailed explanations to ensure your exam success. Gain confidence and get certified!

In Python, multi-line comments are typically created using triple quotes, either single (''') or double ("""). This approach allows you to enclose your comment text across multiple lines, making it very useful for adding explanations or documentation in code that spans more than one line. The use of triple quotes is not limited to comments; it also serves as a way to define multi-line strings.

When surrounded by triple quotes, Python will ignore everything inside, which effectively makes this a way to document code or write comments that are longer than one line. This is particularly helpful for complex code sections or when you need to elaborate on what a function or class is intended to do.

Other symbols like the hash (#) are used for single-line comments, which is useful for brief notes. The other options presented either belong to different programming languages or do not serve the purpose of comments in Python.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy