Search Bar

Saturday 29 April 2023

Python Progrmming Tut#04|Comments in Python

Python Tutorial 04

Comments in Python

In Python programming, comments are text within the code that are ignored by the interpreter or compiler. They are used to explain what the code does, add notes or reminders, or to disable certain parts of the code during testing or debugging.

Comments are useful because they make the code more readable and help other programmers understand your intentions. Python supports two types of comments:

Single-line comments: These start with the hash symbol (#) and continue until the end of the line. Anything after the hash symbol on a line is ignored by the interpreter.


For example:

Python Programming Tutorial 04|Comments in Python
Python Programming Tutorial 04|Comments in Python

Multi-line comments: These start and end with three single (''') or double quotes ("""). Anything between these quotes is ignored by the interpreter. Multi-line comments are also known as docstrings and are often used to document modules, functions, and classes.

For example:
Python Programming Tutorial 04|Comments in Python
Python Programming Tutorial 04|Comments in Python

0 comments:

Post a Comment