Comments in Python

Comments in Python

Lesson Details:
September 17, 2020

Video Transcription: In this lecture we are going to talk about comments in Python this video is brought to you by Appy Pie’s Academy, see comments are used to explain coding statements comments are ignored by the compiler hence they are not included in the byte codes comments come in handy when others are reading your code not only others but if you yourself are reading your code after a long period of time the comments they will be very helpful in making you understand what are the different locations the program where you have what kind of logic you have applied basic objective of comments is to clarify the coding statements comments are also called remarks now we will learn how do we use comments or remarks in Python the first system is using hash symbol if a statement is preceded with hash symbol it becomes a comment line again let me repeat this that it will become a comment aligned it means it will not be treated as part of your code but rather it will be just part of the documentation that means it will just explain a set of statements or a single statement and it will not be executed for example I have written X is equal to 100 and in front of it I have written hash X is being assigned the value hundred now what is this X is being assigned the value entered it is a plain statement and it is not part of the actual code so hence because it is being preceded with hash symbol it will be treated as a comment now in the next line what I am writing is hash then following statement prints value of x following statement prints value of x it will not be becoming the part of the actual code because it is being with her symbol it will be merely treated as a comment line so this is the actual code print value of X is equal to something plus X that will be printed so we have seen her symbol now we will see the next method of giving comments in Python and that is using three x quotation marks so three times Cartesian marks they come in handy when you want to give commands to a block of code if your requirement is to command a block of code that means multiple statements you want to have multiple statements in your comments in that case you use three quotation marks in the beginning and in the end of that block for example Rolo is equal to 1 0 1 taking this variable role new assigning it the value 1 0 1 similarly marks in English assigning it the value 99 and marks in maths assigning it the value 100 now here start from this 3 quotation marks there are three statements and these three quotation marks are getting ended here so this whole block will be treated as comments they will not be part of your actual code they will not be converted into byte codes so this is something in the above statement I have signed values into three variables and in the following statement I will print their values and other thing these are comment lines and will not be compiled into byte codes so this they they all these three statements will become this block will become the comment lines and they will not be part of the actual program so next I have printed roll number marks in English and marks in maths and this is yours familiar with this s clear because roll no and marks in English marks in maths all these three variables they were of integer type so they had to be converted into string using s dia. 

loader
Course content