Understanding Python Comments and Best Practices
Learn the significance of commenting in Python programming to enhance code readability, explain thought processes, find errors, and facilitate code reuse. Explore different methods of commenting in Python, including single-line comments, multi-line comments, and using multi-line strings for comments.
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
AEES Distance Learning Class Subject Module No Module Name : Python Comments : XI : Compute Science : M07 Prepared by : G.Tamil Vendan,PGT(SS),AECS,Jaduguda
Python Comments Programming reflects our way of thinking in order to describe the single steps that we took to solve a problem using a computer. Commenting our code helps explain our thought process, and help us to understand later on the intention of our code. This allows us to more easily find errors, to fix them, to improve the code later on, and to reuse it in other applications as well. Commenting is important to all kinds of projects, no matter whether they are - small, medium, or rather large. It is an essential part of your workflow, and is seen as good practice for developers. Without comments, things can get confusing, real fast. In this Presentation we will understand the various methods of commenting in Python.
Comments can be used to explain Python code. Comments can be used to make the code more readable. Comments can be used to prevent execution when testing code. Creating a Comment Comments starts with a #, and Python will ignore them:
Multi Line Comments Python does not really have a syntax for multi line comments. To add a multiline comment you could insert a # for each line:
Multi Line Comments Or , you can use a multiline string. Since Python will ignore string literals that are not assigned to a variable, you can add a multiline string (triple quotes) in your code, and place your comment inside it: