[no audio]
Friends here
we are going to discuss about comments, 'Comments of Python'.
See before telling about comments
let me open my terminal, right. So guys still I am trying to
work using 'vi' or 'vim'
editors, right. From command line
I am using 'vim' editors.
[no audio]
Let me write simple Python Script first. Suppose
I am going to write 'usage_of_comments
[no audio]
.py', any Python program or script.
So here I am going to explain how to use comments.
Right. So guys first thing, comment is nothing but, suppose you're
writing some Python Script
just assume you have some thousands of lines,
[no audio]
right, and to understand
what is the purpose of your Python Script or
Python program
you have to go with each and every line and you have to understand,
I mean suppose some third person.
So instead of that
you can write somewhere some comments,
some lines representing that, saying that what is the purpose
of this code. Suppose
let us say first of all I am going to write some simple
Python program, some 'a=4', and 'b=5',
and then I am finding 'result=a+b', don't worry
guys how to write this program,
okay, while going forward we will learn how to write. Now
I am trying to print, right, "The addition of and is:",
this is the "".
Just I am printing this,
okay. Let me save this and write it, and let me run this. We'll
check it whether we are able to get the output or not.
Yes, we are getting some output, right. Now see because this
is very simple program by seeing that you can understand
that, yes we are defining two variables and we're finding the addition
of those two variables, and we're printing. But instead of
that I can write some comments somewhere.
So I am writing.
'This is a simple
arithmetic calculator and implemented by suppose'
[no audio]
and when it is implemented, let's say suppose some July 2019,
and what is the 'Version' of this code,
let's say this is "V.1.0".
If you observe guys, these lines are not your Python program
lines, but these are something like comments to give some
information about your Python Script or Python program.
That's why if I run this program, right,
let me delete that last,
yeah, now let me save it,
and if I try to run your script you will get an error.
"This is a simple automatic calculator" is 'invalid syntax'
because that is not a valid syntax.
Actually, this is not the Python program line.
So you are writing something to give information about
your script to the third person, right.
So those lines are comments, and while running your Python
program if you want to skip these lines, these lines you have
to write, each and every line you have to start with the '#'
symbol so that all lines are commented out. Your Python, while
running your Python know your Python won't consider
these lines are as your Python's program lines and simply
your Python will skip these lines. Even though if you write this type
of lines, thousands of lines in your program,
your Python won't consider these lines as a Python Script
line, and then simply it will skip those lines. And your Python
program starts from here, 'a=4', 'b=5', 'result',
and these four lines will execute,
[no audio]
right. Now, let me save it and run it.
Oh, man.
[no audio]
Let me save this. Now,
I am going to run. Now instead of getting an error
you will get output. That's it.
Right. Fine.
So guys now you have to understand that to comment a single
line you can use '#' symbol,
right. Even if you want to comment some thousand lines for
each and every line before starting your line
you have to write '#' symbol.
Let us assume that you are having suppose some 100 comment
lines, and they are in sequence.
Right. So to comment your 100 lines what I have to do? For each
and every line I have to start with '#' symbol, but I am
the lazy person, right, now I am going to use some shortcut.
Whatever the lines you want to comment, all those lines
you can write between triple quotes. Those triple codes may
be single or double. I can use either single quotes three
times or double quotes three times.
Now, this is exactly equals to your placing, if you want
to comment all these four lines, how you're commenting? By
placing '#' symbol on the starting of your each and every
line. Now instead of that you can simply place your commenting
lines, comment lines between these quotations. These are triple
quotes, either single triple quotes or double quotation symbol
three times, right. Now,
let me save this,
and run that, and see the output. Before going to run
let me do one thing.
[no audio]
I am going to see your script.
This is your script, and I am going to run that.
Perfectly working, means your Python now is skipping these lines,
and these lines are commented out.
Okay. So guys comments are two types - single line comments and
multiple line comments.
So single line comments, you can comment with the '#' symbol,
and multiple line comments, in case if you have sometimes
you know, or some sequence of lines, some 100s, or 10s,
or some 50 lines, right, or maybe two lines also, you can comment
with the triple quotes as well. So multiple line comments is triple quotes.
So and remember that it may be single quotation three times
or you have to start with three double quotations, and you
have to end with the three double quotations. That's it.
[no audio]
Okay, I hope it's clear.
Okay guys, thank you for watching this video.
[no audio]