1 00:00:00,000 --> 00:00:01,100 [no audio] 2 00:00:01,110 --> 00:00:02,100 Friends here 3 00:00:02,100 --> 00:00:05,800 we are going to discuss about comments, 'Comments of Python'. 4 00:00:07,100 --> 00:00:08,800 See before telling about comments 5 00:00:09,200 --> 00:00:14,800 let me open my terminal, right. So guys still I am trying to 6 00:00:14,800 --> 00:00:18,200 work using 'vi' or 'vim' 7 00:00:18,200 --> 00:00:20,600 editors, right. From command line 8 00:00:21,100 --> 00:00:23,700 I am using 'vim' editors. 9 00:00:23,700 --> 00:00:25,600 [no audio] 10 00:00:25,600 --> 00:00:28,600 Let me write simple Python Script first. Suppose 11 00:00:28,600 --> 00:00:31,100 I am going to write 'usage_of_comments 12 00:00:31,100 --> 00:00:33,700 [no audio] 13 00:00:33,700 --> 00:00:36,300 .py', any Python program or script. 14 00:00:36,900 --> 00:00:40,000 So here I am going to explain how to use comments. 15 00:00:40,800 --> 00:00:45,900 Right. So guys first thing, comment is nothing but, suppose you're 16 00:00:45,900 --> 00:00:47,300 writing some Python Script 17 00:00:48,000 --> 00:00:50,500 just assume you have some thousands of lines, 18 00:00:50,500 --> 00:00:52,300 [no audio] 19 00:00:52,300 --> 00:00:55,800 right, and to understand 20 00:00:55,800 --> 00:00:58,600 what is the purpose of your Python Script or 21 00:00:58,600 --> 00:00:59,600 Python program 22 00:00:59,600 --> 00:01:01,900 you have to go with each and every line and you have to understand, 23 00:01:02,300 --> 00:01:03,800 I mean suppose some third person. 24 00:01:04,800 --> 00:01:06,000 So instead of that 25 00:01:07,300 --> 00:01:09,500 you can write somewhere some comments, 26 00:01:09,500 --> 00:01:14,800 some lines representing that, saying that what is the purpose 27 00:01:14,800 --> 00:01:16,200 of this code. Suppose 28 00:01:16,200 --> 00:01:18,200 let us say first of all I am going to write some simple 29 00:01:18,200 --> 00:01:22,400 Python program, some 'a=4', and 'b=5', 30 00:01:22,600 --> 00:01:27,200 and then I am finding 'result=a+b', don't worry 31 00:01:27,200 --> 00:01:28,400 guys how to write this program, 32 00:01:28,500 --> 00:01:32,300 okay, while going forward we will learn how to write. Now 33 00:01:32,300 --> 00:01:46,700 I am trying to print, right, "The addition of and is:", 34 00:01:46,700 --> 00:01:48,200 this is the "". 35 00:01:49,400 --> 00:01:50,500 Just I am printing this, 36 00:01:50,600 --> 00:01:55,300 okay. Let me save this and write it, and let me run this. We'll 37 00:01:55,300 --> 00:01:57,600 check it whether we are able to get the output or not. 38 00:01:58,700 --> 00:02:03,400 Yes, we are getting some output, right. Now see because this 39 00:02:03,400 --> 00:02:05,800 is very simple program by seeing that you can understand 40 00:02:05,800 --> 00:02:08,500 that, yes we are defining two variables and we're finding the addition 41 00:02:08,500 --> 00:02:11,500 of those two variables, and we're printing. But instead of 42 00:02:11,500 --> 00:02:14,100 that I can write some comments somewhere. 43 00:02:15,800 --> 00:02:16,800 So I am writing. 44 00:02:18,100 --> 00:02:19,400 'This is a simple 45 00:02:20,900 --> 00:02:28,800 arithmetic calculator and implemented by suppose' 46 00:02:28,800 --> 00:02:33,700 [no audio] 47 00:02:33,700 --> 00:02:43,000 and when it is implemented, let's say suppose some July 2019, 48 00:02:43,000 --> 00:02:44,600 and what is the 'Version' of this code, 49 00:02:45,000 --> 00:02:49,100 let's say this is "V.1.0". 50 00:02:50,600 --> 00:02:54,200 If you observe guys, these lines are not your Python program 51 00:02:54,200 --> 00:02:57,200 lines, but these are something like comments to give some 52 00:02:57,200 --> 00:02:59,900 information about your Python Script or Python program. 53 00:03:00,800 --> 00:03:04,400 That's why if I run this program, right, 54 00:03:04,800 --> 00:03:06,100 let me delete that last, 55 00:03:07,600 --> 00:03:09,600 yeah, now let me save it, 56 00:03:10,700 --> 00:03:15,500 and if I try to run your script you will get an error. 57 00:03:16,900 --> 00:03:20,000 "This is a simple automatic calculator" is 'invalid syntax' 58 00:03:20,000 --> 00:03:21,700 because that is not a valid syntax. 59 00:03:21,700 --> 00:03:24,200 Actually, this is not the Python program line. 60 00:03:25,500 --> 00:03:28,200 So you are writing something to give information about 61 00:03:28,200 --> 00:03:31,200 your script to the third person, right. 62 00:03:31,200 --> 00:03:35,400 So those lines are comments, and while running your Python 63 00:03:35,400 --> 00:03:39,600 program if you want to skip these lines, these lines you have 64 00:03:39,600 --> 00:03:42,500 to write, each and every line you have to start with the '#' 65 00:03:42,500 --> 00:03:47,900 symbol so that all lines are commented out. Your Python, while 66 00:03:47,900 --> 00:03:50,700 running your Python know your Python won't consider 67 00:03:51,000 --> 00:03:54,900 these lines are as your Python's program lines and simply 68 00:03:54,900 --> 00:03:58,600 your Python will skip these lines. Even though if you write this type 69 00:03:58,600 --> 00:04:00,600 of lines, thousands of lines in your program, 70 00:04:01,000 --> 00:04:04,600 your Python won't consider these lines as a Python Script 71 00:04:04,600 --> 00:04:08,600 line, and then simply it will skip those lines. And your Python 72 00:04:08,600 --> 00:04:12,200 program starts from here, 'a=4', 'b=5', 'result', 73 00:04:12,200 --> 00:04:13,900 and these four lines will execute, 74 00:04:13,900 --> 00:04:16,100 [no audio] 75 00:04:16,100 --> 00:04:18,300 right. Now, let me save it and run it. 76 00:04:19,800 --> 00:04:20,800 Oh, man. 77 00:04:20,800 --> 00:04:23,700 [no audio] 78 00:04:23,700 --> 00:04:26,399 Let me save this. Now, 79 00:04:26,399 --> 00:04:29,400 I am going to run. Now instead of getting an error 80 00:04:29,400 --> 00:04:31,200 you will get output. That's it. 81 00:04:32,900 --> 00:04:35,100 Right. Fine. 82 00:04:36,100 --> 00:04:39,700 So guys now you have to understand that to comment a single 83 00:04:39,700 --> 00:04:41,700 line you can use '#' symbol, 84 00:04:43,100 --> 00:04:47,300 right. Even if you want to comment some thousand lines for 85 00:04:47,300 --> 00:04:49,400 each and every line before starting your line 86 00:04:49,400 --> 00:04:50,600 you have to write '#' symbol. 87 00:04:51,600 --> 00:04:55,800 Let us assume that you are having suppose some 100 comment 88 00:04:55,800 --> 00:04:57,600 lines, and they are in sequence. 89 00:04:59,000 --> 00:05:03,000 Right. So to comment your 100 lines what I have to do? For each 90 00:05:03,000 --> 00:05:07,400 and every line I have to start with '#' symbol, but I am 91 00:05:07,400 --> 00:05:12,000 the lazy person, right, now I am going to use some shortcut. 92 00:05:12,000 --> 00:05:16,100 Whatever the lines you want to comment, all those lines 93 00:05:16,100 --> 00:05:21,400 you can write between triple quotes. Those triple codes may 94 00:05:21,400 --> 00:05:24,900 be single or double. I can use either single quotes three 95 00:05:24,900 --> 00:05:26,700 times or double quotes three times. 96 00:05:27,600 --> 00:05:32,000 Now, this is exactly equals to your placing, if you want 97 00:05:32,000 --> 00:05:34,800 to comment all these four lines, how you're commenting? By 98 00:05:34,800 --> 00:05:37,800 placing '#' symbol on the starting of your each and every 99 00:05:37,800 --> 00:05:43,000 line. Now instead of that you can simply place your commenting 100 00:05:43,000 --> 00:05:48,700 lines, comment lines between these quotations. These are triple 101 00:05:48,700 --> 00:05:52,900 quotes, either single triple quotes or double quotation symbol 102 00:05:52,900 --> 00:05:54,900 three times, right. Now, 103 00:05:54,900 --> 00:05:57,200 let me save this, 104 00:05:58,700 --> 00:06:01,400 and run that, and see the output. Before going to run 105 00:06:01,900 --> 00:06:02,800 let me do one thing. 106 00:06:02,800 --> 00:06:04,800 [no audio] 107 00:06:04,800 --> 00:06:07,800 I am going to see your script. 108 00:06:08,000 --> 00:06:10,300 This is your script, and I am going to run that. 109 00:06:11,500 --> 00:06:15,300 Perfectly working, means your Python now is skipping these lines, 110 00:06:16,100 --> 00:06:18,100 and these lines are commented out. 111 00:06:18,900 --> 00:06:23,000 Okay. So guys comments are two types - single line comments and 112 00:06:23,000 --> 00:06:24,200 multiple line comments. 113 00:06:24,200 --> 00:06:26,900 So single line comments, you can comment with the '#' symbol, 114 00:06:27,500 --> 00:06:30,900 and multiple line comments, in case if you have sometimes 115 00:06:30,900 --> 00:06:35,700 you know, or some sequence of lines, some 100s, or 10s, 116 00:06:36,000 --> 00:06:40,100 or some 50 lines, right, or maybe two lines also, you can comment 117 00:06:40,500 --> 00:06:45,200 with the triple quotes as well. So multiple line comments is triple quotes. 118 00:06:45,500 --> 00:06:48,100 So and remember that it may be single quotation three times 119 00:06:49,000 --> 00:06:52,200 or you have to start with three double quotations, and you 120 00:06:52,200 --> 00:06:54,700 have to end with the three double quotations. That's it. 121 00:06:54,700 --> 00:06:57,500 [no audio] 122 00:06:57,500 --> 00:06:58,700 Okay, I hope it's clear. 123 00:06:59,700 --> 00:07:01,600 Okay guys, thank you for watching this video. 124 00:07:01,600 --> 00:07:08,500 [no audio]