1 00:00:00,000 --> 00:00:04,700 [no audio] 2 00:00:04,710 --> 00:00:05,700 Friends here 3 00:00:05,700 --> 00:00:08,900 we are going to discuss about some of these special characters 4 00:00:08,900 --> 00:00:12,700 of Python, right. To explain this, right, 5 00:00:12,700 --> 00:00:16,100 I am going to take one simple Python program or Python Script. 6 00:00:16,100 --> 00:00:17,800 Let me open my terminal first. 7 00:00:17,800 --> 00:00:20,700 [no audio] 8 00:00:20,700 --> 00:00:24,600 Okay, I am moving into 'Desktop'. There actually I have a directory 9 00:00:24,600 --> 00:00:25,900 called 'PythonScripts'. 10 00:00:26,400 --> 00:00:29,700 So here I am going to write a Python Script name called 11 00:00:29,700 --> 00:00:29,710 'special_char.py'. 12 00:00:32,700 --> 00:00:34,700 [no audio] 13 00:00:34,700 --> 00:00:36,600 First I'm going to write one simple Python 14 00:00:36,600 --> 00:00:40,800 program. The purpose of that Python program is simply to 15 00:00:40,800 --> 00:00:46,600 print some information like, "Welcome to python scripting". 16 00:00:47,800 --> 00:00:49,200 Right. I am going to write that one. 17 00:00:49,500 --> 00:00:51,200 Let me write it. 'print' 18 00:00:51,200 --> 00:00:53,200 [no audio] 19 00:00:53,200 --> 00:00:57,300 "Welcome to python scripting". 20 00:00:58,500 --> 00:01:02,500 So what you are doing guys? You are simply printing some string, 21 00:01:04,099 --> 00:01:07,600 okay. So whenever if you want to print a string using 'print' 22 00:01:07,600 --> 00:01:11,800 statement you have to write your string inside of quotation 23 00:01:12,000 --> 00:01:14,200 with your 'print', right? 24 00:01:14,900 --> 00:01:15,900 That's okay. First 25 00:01:15,900 --> 00:01:17,000 let me save it, 26 00:01:17,000 --> 00:01:18,900 [no audio] 27 00:01:18,900 --> 00:01:20,400 and run it. Already 28 00:01:20,400 --> 00:01:24,400 we know how to run your Python scripts, right? 29 00:01:24,700 --> 00:01:26,100 So this is your Python Script. 30 00:01:26,100 --> 00:01:28,900 I am going to run our Python Script in this way. 31 00:01:30,200 --> 00:01:31,800 Yes, you are getting some output. 32 00:01:32,900 --> 00:01:35,400 Guys now I want to print output like 33 00:01:35,400 --> 00:01:42,000 [no audio] 34 00:01:42,000 --> 00:01:44,300 "Welcome to python scripting", 35 00:01:44,300 --> 00:01:49,500 and in the next line I want to write, "This is about special 36 00:01:49,500 --> 00:01:50,900 characters of your python". 37 00:01:51,000 --> 00:01:55,100 So what I have to do? I need to include one more line called, 38 00:01:56,800 --> 00:01:58,600 Right. Let me write it one more line. 39 00:01:58,700 --> 00:02:00,200 So I want to print one more line. 40 00:02:00,200 --> 00:02:02,000 So I have to use one more 'print' statement. 41 00:02:03,500 --> 00:02:09,600 So, "We are working with some special characters". 42 00:02:10,500 --> 00:02:11,500 That's it. 43 00:02:12,199 --> 00:02:13,400 Let me save this, 44 00:02:14,500 --> 00:02:19,100 and run it. Before running just see what is your code. 45 00:02:19,200 --> 00:02:22,700 So this is your code. You are having two lines of Python Script. 46 00:02:23,200 --> 00:02:25,800 So those two lines are simply to print some string. 47 00:02:26,500 --> 00:02:29,500 So whenever if you have a 'print', simply it will print whatever 48 00:02:29,500 --> 00:02:33,000 there inside of your quotations as of now, right. 49 00:02:33,000 --> 00:02:34,000 Let me run it. 50 00:02:35,200 --> 00:02:37,900 Yes, I'm getting two lines of information. 51 00:02:38,900 --> 00:02:42,700 So guys actually you are using immediately two 'print' statements, 52 00:02:43,100 --> 00:02:46,000 first line 'print', second line 'print'. You're printing information 53 00:02:46,000 --> 00:02:48,900 with two 'print' statements. Instead of that 54 00:02:49,100 --> 00:02:51,100 I can use only one 'print' statement, 55 00:02:51,100 --> 00:02:52,500 I can also print this line, 56 00:02:52,700 --> 00:02:54,100 I mean this information, right? 57 00:02:54,800 --> 00:03:00,600 What I will do is, so you know how to comment Python Script lines, 58 00:03:01,400 --> 00:03:03,500 right. You can skip, you can comment any line. 59 00:03:03,500 --> 00:03:05,500 Now, I don't want to run these two lines 60 00:03:05,500 --> 00:03:07,500 that's why I'm commenting. Now, 61 00:03:07,500 --> 00:03:10,500 I am going to write one single 'print' statement in this way. 62 00:03:10,500 --> 00:03:12,600 [no audio] 63 00:03:12,600 --> 00:03:16,600 "Welcome to python scripting", then I am writing 64 00:03:17,700 --> 00:03:22,400 "We are working with special chars". 65 00:03:23,800 --> 00:03:28,000 Yes, this will also work and you will get your output, right. 66 00:03:28,000 --> 00:03:34,100 So before getting output just observe your script once. 67 00:03:34,300 --> 00:03:36,000 Let me clear our screen. Yeah. 68 00:03:37,500 --> 00:03:41,400 This is your script output you're getting. But my intention 69 00:03:41,400 --> 00:03:45,400 is I want to print this information in one line, and this 70 00:03:45,400 --> 00:03:47,900 information in next line. Here actually we're getting both the 71 00:03:47,900 --> 00:03:49,100 information in a single line. 72 00:03:49,800 --> 00:03:51,700 So at that time what I can do is 73 00:03:51,700 --> 00:03:53,700 [no audio] 74 00:03:53,700 --> 00:03:55,400 open your script once. 75 00:03:55,400 --> 00:03:57,300 [no audio] 76 00:03:57,300 --> 00:04:01,600 From which information you want to print that information 77 00:04:01,600 --> 00:04:05,000 in the next line, just before that write "/n", 78 00:04:07,000 --> 00:04:08,000 and save it. 79 00:04:08,000 --> 00:04:09,900 [no audio] 80 00:04:09,900 --> 00:04:13,900 Right. Now this is your script. 81 00:04:14,300 --> 00:04:15,700 We have only one line guys. 82 00:04:15,700 --> 00:04:17,100 First two lines are commented. 83 00:04:17,100 --> 00:04:19,700 That means your Python Script won't execute first two lines. 84 00:04:20,300 --> 00:04:24,399 Now, I am running. You are getting your output in two lines. Now here 85 00:04:24,399 --> 00:04:28,000 "/n" is the special character, and it is called new line. 86 00:04:28,399 --> 00:04:32,500 So whenever if you include "/n", after "/n" whatever you are 87 00:04:32,500 --> 00:04:35,500 having that info you will get in the next line, like this. 88 00:04:37,100 --> 00:04:40,400 Right. So guys you are having some special characters. 89 00:04:40,600 --> 00:04:44,900 Let me discuss at least some of them and while going forward 90 00:04:45,200 --> 00:04:49,000 we will discuss remaining things based on requirements, right. 91 00:04:49,500 --> 00:04:50,400 See first thing, 92 00:04:50,400 --> 00:04:53,700 [no audio] 93 00:04:53,700 --> 00:04:57,400 special characters you have to write always your special 94 00:04:57,400 --> 00:04:59,800 characters inside of your quotations. 95 00:04:59,800 --> 00:05:01,900 [no audio] 96 00:05:01,900 --> 00:05:10,100 Write special chars only inside of quotes. That quotes 97 00:05:10,100 --> 00:05:16,400 maybe single quotations or some double quotations. You can 98 00:05:16,400 --> 00:05:18,800 use any one of that, right. Now 99 00:05:18,800 --> 00:05:21,600 very first one what we are discussing, is this is called 100 00:05:21,600 --> 00:05:22,600 'New line', 101 00:05:22,600 --> 00:05:26,100 [no audio] 102 00:05:26,100 --> 00:05:29,600 right. Now, let me go with the "/b", and this is 103 00:05:29,600 --> 00:05:31,600 called backspace. 104 00:05:31,600 --> 00:05:40,500 [no audio] 105 00:05:40,500 --> 00:05:41,800 See how it is going to work. 106 00:05:43,200 --> 00:05:48,300 So guys whatever you are having inside of your script that 107 00:05:48,300 --> 00:05:51,800 thing you can also run from your Python Shell. Just simply 108 00:05:51,800 --> 00:05:54,900 type on your command line 'python', and then you will enter 109 00:05:55,200 --> 00:05:56,400 into your Python Shell. 110 00:05:57,000 --> 00:06:02,800 Let me copy this line and paste it on your Python command 111 00:06:02,800 --> 00:06:05,800 line or Python Shell, and 'Enter'. See the output. 112 00:06:07,100 --> 00:06:08,600 Right. Now from here 113 00:06:08,600 --> 00:06:11,200 I am explaining your special characters. 114 00:06:12,400 --> 00:06:14,500 So whatever I am going to type here same thing 115 00:06:14,500 --> 00:06:16,500 you can write into one file, and I can execute. 116 00:06:16,800 --> 00:06:18,900 I mean you can create one Python Script and you can execute 117 00:06:18,900 --> 00:06:20,900 it. Let me 'print' simply 118 00:06:22,600 --> 00:06:27,500 "Hello World". You're getting some output no. 119 00:06:27,800 --> 00:06:31,600 Now what I am doing is just before your "World" 120 00:06:31,700 --> 00:06:36,600 I am writing "/b", and see the output. There is no space between 121 00:06:36,600 --> 00:06:37,600 your two words. 122 00:06:39,300 --> 00:06:46,300 Right. The reason is "/b" will send your cursor position back, one 123 00:06:46,300 --> 00:06:47,300 position back. 124 00:06:47,600 --> 00:06:49,300 That's why after "Hello" 125 00:06:49,300 --> 00:06:52,600 actually you have a space, right? That space will be removed 126 00:06:52,700 --> 00:06:55,200 because your cursor is coming back one position. 127 00:06:55,300 --> 00:06:56,800 That is the purpose of "/b". 128 00:06:57,300 --> 00:07:01,400 So if I write two "/b", right, because of one "/b" your cursor 129 00:07:01,400 --> 00:07:04,500 will come back one position, and second one more position 130 00:07:04,500 --> 00:07:05,500 back, see that. 131 00:07:06,300 --> 00:07:09,700 'o' is missing. So actually first your python will type 132 00:07:09,700 --> 00:07:13,500 "Hello", after that because of this "/b" your cursor will come 133 00:07:13,500 --> 00:07:16,800 to this position, again one more "/b", because of that your 134 00:07:16,800 --> 00:07:20,100 cursor will come to this "o" position, and from there onwards 135 00:07:20,100 --> 00:07:22,000 your next word will type. 136 00:07:23,700 --> 00:07:25,300 If I write three "/b", 137 00:07:25,300 --> 00:07:29,800 [no audio] 138 00:07:29,800 --> 00:07:30,800 see the output. 139 00:07:31,500 --> 00:07:33,600 So your cursor will come back three position, 140 00:07:34,700 --> 00:07:36,100 positions, and from there 141 00:07:36,100 --> 00:07:38,200 it will try to overwrite your existing information with the 142 00:07:38,200 --> 00:07:39,800 new information whatever it is 143 00:07:39,800 --> 00:07:41,700 there after your "/b". 144 00:07:41,700 --> 00:07:43,800 [no audio] 145 00:07:43,800 --> 00:07:50,900 Right. So that is the "/b". Now "/t". "/t" - tab. You know tab. What 146 00:07:50,900 --> 00:07:52,200 is the purpose of tab, right? 147 00:07:52,500 --> 00:07:54,700 Let me show you that here, it's very simple. 148 00:07:54,800 --> 00:07:57,400 So without a tab what is the output, and with the tab 149 00:07:57,400 --> 00:07:59,700 what is the output? Just you're providing tab space 150 00:07:59,700 --> 00:08:00,700 in the output. That's it. 151 00:08:00,700 --> 00:08:04,300 [no audio] 152 00:08:04,300 --> 00:08:07,600 Right. Fine. Next thing. 153 00:08:07,600 --> 00:08:10,100 [no audio] 154 00:08:10,100 --> 00:08:13,600 See guys suppose I want to print information like this, 'print(" 155 00:08:13,600 --> 00:08:16,400 [no audio] 156 00:08:16,400 --> 00:08:17,400 python's 157 00:08:17,400 --> 00:08:21,300 [no audio] 158 00:08:21,300 --> 00:08:22,600 class")', something like that. 159 00:08:22,600 --> 00:08:26,500 Yes, it's working perfectly, right? Now first observe this 160 00:08:26,500 --> 00:08:29,600 one. So in your 'print' statements you can also use instead 161 00:08:29,600 --> 00:08:30,700 of double quotation 162 00:08:30,700 --> 00:08:32,500 you can also use single quotations. 163 00:08:32,500 --> 00:08:33,700 No problem, it will work. 164 00:08:35,100 --> 00:08:39,900 But in this case if I try to write "python's", you will get a syntax 165 00:08:39,900 --> 00:08:43,900 error. "invalid syntax", you are getting. The reason is, 166 00:08:45,000 --> 00:08:48,799 so 'print', you are printing some string. String should be there 167 00:08:48,799 --> 00:08:50,000 inside of your quotation. 168 00:08:50,400 --> 00:08:53,200 Actually your Python will take this as a starting quotation, 169 00:08:53,200 --> 00:08:56,299 and this as the ending quotation. Then what about this information? 170 00:08:57,700 --> 00:09:01,500 So now what you have to do is, this is the starting quotation, 171 00:09:01,600 --> 00:09:04,700 and this is ending quotation, and you have to escape here. 172 00:09:06,100 --> 00:09:08,900 Right. Your Python should not consider this as a quotation, 173 00:09:08,900 --> 00:09:13,100 single quotation. Then in that case you have to write a "\", escape 174 00:09:13,100 --> 00:09:16,700 symbol "\". Now because of that what it will do is, your Python 175 00:09:16,700 --> 00:09:20,400 simply will skip this as a quotation. It will take this as 176 00:09:20,400 --> 00:09:24,300 some letter, some character, and it will preserve in the output. 177 00:09:24,300 --> 00:09:25,300 See the output. 178 00:09:26,600 --> 00:09:27,700 Now it is not like a quotation. 179 00:09:27,700 --> 00:09:29,800 It is like other than quotation some character. 180 00:09:29,800 --> 00:09:32,100 [no audio] 181 00:09:32,100 --> 00:09:35,100 Right. Fine. Not only that, 182 00:09:35,100 --> 00:09:37,200 sometimes you have to write, suppose 183 00:09:37,300 --> 00:09:43,200 "This is a python class", and you want to write 'python' in double quotations 184 00:09:43,200 --> 00:09:46,000 [no audio] 185 00:09:46,000 --> 00:09:48,600 So you know, this is starting and this is ending, 186 00:09:48,800 --> 00:09:52,700 but between if you have any quotations, right you can escape 187 00:09:52,700 --> 00:09:56,300 from that simply. As of now if I run you will get an error 188 00:09:56,300 --> 00:10:00,700 guys. I mean an "invalid syntax" you will get. Only starting 189 00:10:00,700 --> 00:10:04,300 and ending quotation is for your string. In middle 190 00:10:04,300 --> 00:10:07,600 if you get any quotations you have to escape from the purpose 191 00:10:07,600 --> 00:10:12,000 of your quotations. At that time you have to write simply "\" so that 192 00:10:12,300 --> 00:10:16,900 your quotations will be considered as any character other than 193 00:10:17,000 --> 00:10:25,400 your quotations. Now see that. Right. Now "\" is for escape symbol. 194 00:10:25,400 --> 00:10:33,800 [no audio] 195 00:10:33,800 --> 00:10:35,200 Okay, then. 196 00:10:35,200 --> 00:10:37,200 [no audio] 197 00:10:37,200 --> 00:10:38,200 Let me do one thing. 198 00:10:39,400 --> 00:10:41,100 So I will do one thing guys. 199 00:10:42,500 --> 00:10:44,100 Let me go with my desktop. 200 00:10:45,300 --> 00:10:47,900 It may be any folder. 201 00:10:48,200 --> 00:10:51,400 So here what I am doing is I'm creating a new folder called 202 00:10:51,400 --> 00:10:53,900 [no audio] 203 00:10:53,900 --> 00:10:57,900 "new" itself, right. So I am going to create simply "new". 204 00:10:59,300 --> 00:11:00,800 Then what is the path of this? 205 00:11:01,000 --> 00:11:02,300 So this is the path, right? 206 00:11:03,000 --> 00:11:06,500 Let me print this path with your Python. Because that is a 207 00:11:06,500 --> 00:11:09,700 string I can print it but see the output what you are getting. 208 00:11:09,700 --> 00:11:13,400 [no audio] 209 00:11:13,400 --> 00:11:19,000 Right. See guys, whenever if you are providing your path in your 210 00:11:19,100 --> 00:11:24,600 Python that too only Windows path because in Windows you have 211 00:11:24,600 --> 00:11:28,800 this "\", but whereas in Linux you have "/", 212 00:11:29,800 --> 00:11:31,400 so this is the problem. Already 213 00:11:31,400 --> 00:11:36,500 we know this "\" is for our escape symbol purpose, but in 214 00:11:36,500 --> 00:11:40,400 your Python, I mean in the path, in Windows path you have that symbol 215 00:11:41,400 --> 00:11:44,400 Right. Now you have to escape from that symbol. 216 00:11:45,100 --> 00:11:48,000 So actually, you know to escape from any character you're 217 00:11:48,000 --> 00:11:49,000 using Escape symbol. 218 00:11:49,200 --> 00:11:53,100 This "\" in your Python. The same way you can use in your 219 00:11:53,100 --> 00:11:56,500 Python Windows path also in this way, 220 00:11:57,900 --> 00:12:00,600 or simply remember that whenever if you are providing Windows 221 00:12:00,600 --> 00:12:05,600 path, you have to write two slashes manually. If your Python 222 00:12:05,600 --> 00:12:08,200 script is going to find any path through logic, you don't 223 00:12:08,200 --> 00:12:11,900 for that you don't need to worry, but if you are providing 224 00:12:11,900 --> 00:12:15,800 manually some Windows path while working with your Python 225 00:12:15,800 --> 00:12:18,700 scripts there you have to write two slashes in your path 226 00:12:18,900 --> 00:12:20,000 then only it will work. 227 00:12:20,000 --> 00:12:23,600 [no audio] 228 00:12:23,600 --> 00:12:28,400 Right. So this is very, very important guys. Those who are working Python 229 00:12:28,400 --> 00:12:30,700 [no audio] 230 00:12:30,700 --> 00:12:31,700 for Windows, 231 00:12:32,800 --> 00:12:35,500 okay. If you are working with your Windows using Python, 232 00:12:35,900 --> 00:12:40,900 so whenever if you are entering path manually, Windows path, 233 00:12:40,900 --> 00:12:44,000 only Windows path, there is no problem with your Unix Systems 234 00:12:44,000 --> 00:12:46,800 paths, then instead of "\" 235 00:12:46,800 --> 00:12:48,400 you have to provide "\\". 236 00:12:49,600 --> 00:12:50,600 Right. 237 00:12:50,600 --> 00:12:52,600 [no audio] 238 00:12:52,600 --> 00:12:55,100 Okay, so guys there is, there are some other symbols 239 00:12:55,100 --> 00:13:00,300 as well like "\a", it will create an alert sound. Alert sound, right. 240 00:13:00,300 --> 00:13:03,000 [no audio] 241 00:13:03,000 --> 00:13:06,700 Okay. So we have some more things. While going forward 242 00:13:06,700 --> 00:13:09,800 we'll discuss some of other special characters as well. 243 00:13:09,900 --> 00:13:12,800 So for time being you have to know this minimum special characters 244 00:13:12,800 --> 00:13:15,600 to work with your Python, right? 245 00:13:16,300 --> 00:13:18,400 Okay guys, thank you for watching this video. 246 00:13:18,400 --> 00:13:24,800 [no audio]