Python Commentary – Tutorial (1.1)

Python Commentary – Tutorial
Python Commentary – Tutorial

Python Commentary – Python is a development language that has become very popular in application development. We’ll continue moving forward by looking at how to make comments in code.

Previous tutorial: Python Tutorial – My First Program (1)

Python Commenting

Commenting is crucial in Python to provide non-executable notes that help clarify the code. It allows developers to leave annotations for better code understanding.

To write a comment, use the # symbol, followed by the note you want to leave. Here’s a simple example:

# This is a line to print "Hello World"
print("Hello World")

You can also place the comment after your instruction, like this:

print("Hello World") # Display "Hello World"

There’s a neat trick to create multiline comments without the need to start each line with #. Use three quotation marks """ to begin your comment and three quotation marks to end it. Here’s an example:

"""
My program allows
to display "Hello World"
"""

print("Hello World")

In reality, this is not a true Python comment but rather a multiline text in the program. Since there are no additional instructions, this part is ignored by the program. While it might seem peculiar at first, this practice can prove very useful.

Conclusion

Python Commenting – We will delve deeper in the next chapter of Python, which still holds many secrets.

Next Chapter: Python Tutorial String – Character Strings (3)

(Visited 25 times, 1 visits today)
About Judicaël Paquet 368 Articles
Judicaël Paquet (agile coach and senior devops) My Engagements in France and Switzerland: - Crafting Agile Transformation Strategies - Tailored Agile Training Programs - Raising Awareness and Coaching for Managers - Assessing Agile Maturity and Situational Analysis - Agile Coaching for Teams, Organizations, Product Owners, Scrum Masters, and Agile Coaches Areas of Expertise: Scrum, Kanban, Management 3.0, Scalability, Lean Startup, Agile Methodology.

Be the first to comment

Leave a Reply

Your email address will not be published.


*