1 00:00:00,690 --> 00:00:06,900 We are going to discuss Biton strings, the string is nothing but sequence of characters, and these 2 00:00:06,900 --> 00:00:13,550 characters can be of Lorqess, alphabet's, uppercase alphabets, digits and some special characters. 3 00:00:14,370 --> 00:00:21,920 A string is a sequence of characters and string can contain alphabet's digits and special characters. 4 00:00:22,380 --> 00:00:27,120 Computers do not deal with the characters computer convert them into numbers. 5 00:00:27,130 --> 00:00:28,760 That is a binary number system. 6 00:00:28,950 --> 00:00:33,840 That means each and every character will be represented in the form of zeros and ones. 7 00:00:34,200 --> 00:00:40,350 Even though we may see characters on our screen internally, it is being stored and manipulated as a 8 00:00:40,350 --> 00:00:43,960 combination of zeros and ones in the binary representation. 9 00:00:44,520 --> 00:00:52,470 This conversion of character to a number is called encoding, and the reverse process is known as decoding. 10 00:00:52,650 --> 00:00:55,450 So encoding means from character to the binary. 11 00:00:55,450 --> 00:01:00,950 The presentation and decoding means from the binary presentation to the character generation. 12 00:01:01,470 --> 00:01:07,480 So ASCII and Unicode are the sum of the very popular encoding techniques we use. 13 00:01:07,920 --> 00:01:10,560 So for this better idea on the python strings. 14 00:01:10,710 --> 00:01:17,210 So let us go for practical demonstration right now in Python string means sequence of characters. 15 00:01:17,550 --> 00:01:18,610 So let us define that. 16 00:01:18,630 --> 00:01:21,470 What are the different ways to define a string in Python? 17 00:01:21,960 --> 00:01:24,180 So there is no one that is here. 18 00:01:24,190 --> 00:01:26,740 This will come has been enclosed within a single course. 19 00:01:27,120 --> 00:01:31,500 So if we go on printing, this might instead one I'm getting this will come here. 20 00:01:31,920 --> 00:01:37,060 Here will come is enclosed within double codes here will come is enclosed within tripled single course. 21 00:01:37,320 --> 00:01:40,040 So in this way we are getting this welcome God printed. 22 00:01:40,290 --> 00:01:46,200 Now here we are having this triple cinequest triple double rather also can use as a single code. 23 00:01:46,200 --> 00:01:47,150 So that is not an issue. 24 00:01:47,520 --> 00:01:50,010 So print Maistre three, it will go on printing. 25 00:01:50,020 --> 00:01:53,490 That is welcome to the world of Python programming. 26 00:01:53,820 --> 00:01:57,840 So triple codes, a string can extent multiple lines. 27 00:01:58,140 --> 00:02:03,600 So in place of this single double code, if we can put a single triple code here, then what we the 28 00:02:03,600 --> 00:02:07,900 outcome are going to get any change in the outcome in the case. 29 00:02:08,820 --> 00:02:14,280 So let me go for execution on finding that I'm getting the same output as I got earlier. 30 00:02:14,670 --> 00:02:16,520 So accessing characters in the string. 31 00:02:16,530 --> 00:02:18,810 So here my state is equal to language. 32 00:02:18,810 --> 00:02:21,120 And then I printed this my estimate here. 33 00:02:21,120 --> 00:02:27,770 So language has got printed and then I'm retrieving the character at the Zero Index, so I shall tip 34 00:02:27,840 --> 00:02:28,110 this. 35 00:02:28,110 --> 00:02:30,990 L So l has got print it now minus one. 36 00:02:31,470 --> 00:02:36,930 That means from the last from the back where this, this particular E is having the index minus one 37 00:02:37,320 --> 00:02:40,920 and from the front this E will have the index that is zero. 38 00:02:40,920 --> 00:02:43,840 One, two, three, four, five, six, seven. 39 00:02:44,310 --> 00:02:48,240 So if we, if we print there seven, if we just I'm just printing here the once again. 40 00:02:49,790 --> 00:02:56,480 So you can find that so in the bookcases, in the bookcases I shall be getting, this has got printed 41 00:02:56,540 --> 00:02:58,160 at seven or minus one. 42 00:02:58,520 --> 00:03:04,910 So minus one means that there is a starting character index from the from the back, from the tail of 43 00:03:04,910 --> 00:03:05,350 the string. 44 00:03:05,870 --> 00:03:07,360 So next one is one to five. 45 00:03:07,520 --> 00:03:13,430 That means index number one, two, three and four because five will be almost exclusively the stopping 46 00:03:13,460 --> 00:03:15,630 index number will be almost exclusive. 47 00:03:15,800 --> 00:03:19,040 So one, two, five mins, one, two, three, four. 48 00:03:19,430 --> 00:03:24,820 So here we are mentioning this this one and why they were separated by this column. 49 00:03:25,250 --> 00:03:27,790 So that is my zero so zero I'm not going to take. 50 00:03:27,800 --> 00:03:31,240 So there is a character at the present index one. 51 00:03:31,250 --> 00:03:33,480 So one, two, three, four. 52 00:03:33,830 --> 00:03:38,260 So I've taken this eight and G.U. and you see we are getting this output like this. 53 00:03:38,750 --> 00:03:43,910 So now here I am having this four minus two sorry, five minus two. 54 00:03:43,940 --> 00:03:44,990 So there is a five year. 55 00:03:45,350 --> 00:03:49,840 So I'm going to take this one as zero one, two, three, four, five. 56 00:03:50,120 --> 00:03:53,190 So that means we're having this one as five here. 57 00:03:53,480 --> 00:03:55,820 So now we are having this one as minus two. 58 00:03:56,060 --> 00:03:57,230 So that is minus one. 59 00:03:57,230 --> 00:04:02,650 Minus two, you know, that will be will be taking this stopping index as exclusive. 60 00:04:02,900 --> 00:04:04,850 So I'll be remaining with this only. 61 00:04:05,000 --> 00:04:06,490 So it has got printed. 62 00:04:06,890 --> 00:04:13,520 So that means Hypercolor minus two means from the character and to the minus three characters. 63 00:04:13,640 --> 00:04:18,230 So minus three means this is my minus one, these are minus two and minus three. 64 00:04:18,230 --> 00:04:20,320 So that's, that's why it has got printed. 65 00:04:20,720 --> 00:04:26,750 So but if I make this one sport, if I make this minus four, then obviously we're getting the output 66 00:04:26,750 --> 00:04:27,350 like this. 67 00:04:27,350 --> 00:04:29,320 So that is you eight in that case. 68 00:04:29,580 --> 00:04:31,070 Now here you see this 10. 69 00:04:31,070 --> 00:04:37,010 The index is not present here because this language is having we are having, say, eight characters. 70 00:04:37,010 --> 00:04:39,100 So index will be ranging from zero to seven. 71 00:04:39,110 --> 00:04:41,390 So then index is not a valid one. 72 00:04:41,420 --> 00:04:48,170 So if I want to access the 10th character, so character at the 10th index, so we are getting this 73 00:04:48,170 --> 00:04:51,260 index error, so string index out of French. 74 00:04:51,260 --> 00:04:53,060 So that is the error message you are getting here. 75 00:04:53,420 --> 00:04:55,000 OK, now we're going for this. 76 00:04:55,640 --> 00:04:57,860 So here we have defined this language. 77 00:04:57,860 --> 00:04:59,570 So strings are immutable. 78 00:04:59,570 --> 00:05:04,750 That means they cannot be changed, but the different strings can be assigned to the string object. 79 00:05:05,000 --> 00:05:08,000 So if we bring this mindstate, I'm getting this language. 80 00:05:08,480 --> 00:05:14,150 But if we if we want to update it, I want to put another new string to this milestone in the same biddable 81 00:05:14,420 --> 00:05:20,690 that is allowed by default to update the third character of the string that is not allowed as it is 82 00:05:20,690 --> 00:05:21,260 immutable. 83 00:05:24,520 --> 00:05:30,040 So there is a time period and it's their object does not support item, item assignment, so that is 84 00:05:30,040 --> 00:05:34,480 that there is an error message we are getting and in the error name is type error. 85 00:05:35,080 --> 00:05:40,840 Next one, we're going for the concatenation of the string and that can be done using plus so dear one 86 00:05:40,840 --> 00:05:45,100 and my two containing welcome and one blank space and then two on. 87 00:05:45,550 --> 00:05:49,210 So now when they are going for the concatenation I'm getting the outcome. 88 00:05:49,210 --> 00:05:49,660 This one. 89 00:05:49,670 --> 00:05:56,050 So welcome to all this blank space is essential because otherwise this will come and two will not have 90 00:05:56,050 --> 00:05:56,920 any separation. 91 00:05:57,220 --> 00:05:58,720 So they will get concatenated. 92 00:05:58,720 --> 00:05:59,320 Side-By-Side. 93 00:06:00,040 --> 00:06:04,590 So now here you are having this, that is my Mystere start three. 94 00:06:04,600 --> 00:06:07,060 So what will happen to my Asgeir start three. 95 00:06:07,130 --> 00:06:12,810 So this particular my dear, will be orcharding for my usted one will be orcharding for three times. 96 00:06:13,090 --> 00:06:14,800 So welcome, welcome, welcome. 97 00:06:14,830 --> 00:06:22,330 So in this way we are going to get the request from the string so we can do the string on concatenation, 98 00:06:22,330 --> 00:06:26,040 either using star or using the plus operators. 99 00:06:27,040 --> 00:06:30,490 Now we're going to discuss or plot and start what I have discussed. 100 00:06:30,490 --> 00:06:33,100 No iterating through our string here. 101 00:06:33,400 --> 00:06:35,160 So later, count is digital. 102 00:06:35,440 --> 00:06:40,910 So four letters in haloed if the letter is is going to is equal to L. 103 00:06:41,230 --> 00:06:43,570 So now letter count is equal to one. 104 00:06:43,600 --> 00:06:44,420 So what will happen? 105 00:06:44,440 --> 00:06:48,950 So I will go on counting the number of occurrences of this character. 106 00:06:49,510 --> 00:06:54,460 So that's why each and every time the volume for Loop will pick up one character at a time and that 107 00:06:54,460 --> 00:06:55,630 will be put in the letters. 108 00:06:55,930 --> 00:06:59,920 So if letters is integral to the letter, count will be increased by one. 109 00:07:00,220 --> 00:07:05,290 And after exiting from the indentation, you are getting this idea that this print is outside of the 110 00:07:05,410 --> 00:07:06,370 for loop. 111 00:07:06,640 --> 00:07:08,860 So letter count will be printed accordingly. 112 00:07:08,890 --> 00:07:11,230 So if you go on executing, I'm getting that three times. 113 00:07:11,470 --> 00:07:13,600 Each letter has been found here. 114 00:07:14,320 --> 00:07:16,120 Now we are going for the string membership. 115 00:07:16,510 --> 00:07:18,000 So L in hello. 116 00:07:18,010 --> 00:07:21,340 So Alien Hello will return true lotting. 117 00:07:21,340 --> 00:07:24,880 Hello will return false B in hello will return false. 118 00:07:25,090 --> 00:07:26,410 B not in hello. 119 00:07:26,410 --> 00:07:27,490 Will return still here. 120 00:07:30,010 --> 00:07:35,760 Built in functions, built in function, so we're having this university and then we shall go for the 121 00:07:35,770 --> 00:07:39,700 enumerate, so least enumerate Mystere. 122 00:07:39,970 --> 00:07:40,810 So what will happen? 123 00:07:40,810 --> 00:07:43,380 It'll go on forming this enumeration. 124 00:07:43,720 --> 00:07:48,350 So at first it'll put the respective respective index. 125 00:07:48,400 --> 00:07:50,810 And then we're having the respective character here. 126 00:07:51,250 --> 00:07:53,200 So in this way, we're having this index zero. 127 00:07:53,200 --> 00:07:59,350 You index one end in this way or having this index nine y because universities having 10 characters. 128 00:07:59,350 --> 00:08:01,540 So index will be ranging from zero to nine. 129 00:08:01,750 --> 00:08:03,140 And in this way you are getting it. 130 00:08:03,520 --> 00:08:09,010 So here you see we are forming a list, we are forming a list because we are just converting it to a 131 00:08:09,010 --> 00:08:09,430 list. 132 00:08:09,550 --> 00:08:14,890 And then the members are nothing but that tuples that members are nothing but a tuples because they 133 00:08:14,890 --> 00:08:19,090 have got separated by commas and they have got enclose within Fastback. 134 00:08:19,090 --> 00:08:22,600 And so they are the simple, simple tuples on list of couples who are getting hit. 135 00:08:23,200 --> 00:08:26,110 A list of Mystere will be then accordingly. 136 00:08:26,740 --> 00:08:30,010 And here we have used a method that is the enumerate. 137 00:08:33,590 --> 00:08:36,290 Now, we shall deal with this single quote, end quote. 138 00:08:36,440 --> 00:08:38,570 So what we shall do that? 139 00:08:38,570 --> 00:08:40,370 Let us suppose I'm going to print this one. 140 00:08:41,800 --> 00:08:45,850 So when I'm going to bring this one, it is producing one error, right, error, because this is a 141 00:08:45,850 --> 00:08:47,680 double code, this is one double code. 142 00:08:47,680 --> 00:08:51,520 So it'll take this double header dominating as a dominating double gold. 143 00:08:51,970 --> 00:08:53,760 So that's why it is causing error here. 144 00:08:54,190 --> 00:08:56,430 And also this what is it? 145 00:08:57,280 --> 00:09:01,680 It is telling that invalid syntax because the codes are not matching. 146 00:09:02,200 --> 00:09:03,530 So quotes are not balanced. 147 00:09:03,530 --> 00:09:09,920 So to right the statement here to write the string getting printed on the output, we can go for this. 148 00:09:10,300 --> 00:09:17,230 So what we are doing, we're enclosing it within single quotes and this particular string is still within 149 00:09:17,230 --> 00:09:17,450 double. 150 00:09:17,690 --> 00:09:19,780 So now you see we're getting Dropcam like this. 151 00:09:20,260 --> 00:09:27,160 Others, we can include the mainstream within single codes and putting this one as the double code can 152 00:09:27,160 --> 00:09:27,400 here. 153 00:09:27,410 --> 00:09:32,860 This particular single code is there and we are going for the escape character. 154 00:09:32,870 --> 00:09:38,460 So there is a single code and which will be known as escape goats that escape single codes. 155 00:09:38,620 --> 00:09:43,640 So whenever we are going to print, it will print their respective only this single code here. 156 00:09:44,260 --> 00:09:47,120 So now we are having this skipping single code. 157 00:09:47,140 --> 00:09:49,540 So now in closing, we're doing the reverse. 158 00:09:49,540 --> 00:09:53,890 Actually, here we have put this single code as an outer one and double code. 159 00:09:53,890 --> 00:09:55,060 That is the inner one. 160 00:09:55,060 --> 00:10:00,310 But if you go for the double cross as the outer one and single course as the inner one, then obviously 161 00:10:00,310 --> 00:10:02,470 this single course will get printed here. 162 00:10:02,890 --> 00:10:04,740 Otherwise we can go for this. 163 00:10:05,110 --> 00:10:07,420 That means we can skipping double codes. 164 00:10:07,420 --> 00:10:10,030 That means we're going for this slash double code. 165 00:10:10,030 --> 00:10:15,310 So here, this double code will be treated as a cat character, not the beginning of the of the ending 166 00:10:15,310 --> 00:10:15,930 of a string. 167 00:10:16,210 --> 00:10:19,470 So that's why we are going for the escaping double also. 168 00:10:19,870 --> 00:10:21,650 So when the string will get printed. 169 00:10:21,670 --> 00:10:27,550 So slash double code will be printed as only a single a double code and slash double code will be printed 170 00:10:27,550 --> 00:10:29,750 as only a single as a single double code. 171 00:10:30,070 --> 00:10:32,680 And here we are having this single code is there. 172 00:10:32,680 --> 00:10:34,210 So that will not cause any problem. 173 00:10:34,420 --> 00:10:38,440 So in this way, the string can be printed in various of ways. 174 00:10:40,030 --> 00:10:47,620 So either using triple quotes or using escaping the single codes, escape into single codes once again 175 00:10:47,620 --> 00:10:50,410 and then escaping the double codes once again. 176 00:10:54,230 --> 00:10:59,360 Next, we are going for this, so here you see this is a print, I want to make it printed. 177 00:10:59,840 --> 00:11:03,300 So whenever we are having double slash, it will print as single slash. 178 00:11:03,300 --> 00:11:06,290 Here you can find we are printing this one as a single slash. 179 00:11:07,260 --> 00:11:12,840 But actually, industry, we're having the double slash, so this is having a new line, there is a 180 00:11:12,840 --> 00:11:14,460 slash and so what will happen? 181 00:11:14,460 --> 00:11:16,860 It'll go to the next line without having to slash. 182 00:11:17,100 --> 00:11:17,790 There is a gap. 183 00:11:17,790 --> 00:11:20,970 So there is a separate is there for eight characters. 184 00:11:21,270 --> 00:11:25,290 And then we can also write in this way, that is slash X 41. 185 00:11:25,290 --> 00:11:28,340 So 41 will be treated as in hexadecimal. 186 00:11:28,590 --> 00:11:30,930 So what is the decimal value against four to one? 187 00:11:31,170 --> 00:11:36,600 So forward into six to the one that is 64 plus one in two six zero. 188 00:11:36,660 --> 00:11:37,360 That is one. 189 00:11:37,740 --> 00:11:39,120 So 64 plus one. 190 00:11:39,120 --> 00:11:39,960 That is 65. 191 00:11:40,200 --> 00:11:43,110 Which character is having this asking for six to five. 192 00:11:43,110 --> 00:11:44,370 That is of a capital eight. 193 00:11:44,550 --> 00:11:50,010 So it is similarly we are having this capital B, similarly we are having this capital C, so this ABC 194 00:11:50,010 --> 00:11:50,610 will be there. 195 00:11:51,000 --> 00:11:53,850 So in this way, you can also print the respective string. 196 00:11:55,130 --> 00:11:58,520 What having this format so different order is equal to. 197 00:11:58,550 --> 00:12:03,610 So now we here to see these other different placeholders, we're having DOT format. 198 00:12:03,830 --> 00:12:09,420 So today will be coming to this is going to be coming to this and Sunday will be coming to this placeholder. 199 00:12:09,740 --> 00:12:11,810 So here we are having this default order. 200 00:12:11,810 --> 00:12:14,750 If we go on printing, I'm getting the output like this one. 201 00:12:16,410 --> 00:12:24,540 So today is and Sunday, so we are getting this, today is and Sunday, so today is coming to this is 202 00:12:24,560 --> 00:12:25,210 is coming today. 203 00:12:25,230 --> 00:12:26,480 So they are maintaining the order. 204 00:12:26,490 --> 00:12:28,410 There is a default implicit order. 205 00:12:28,710 --> 00:12:30,840 And here you are using this format method. 206 00:12:31,260 --> 00:12:33,610 So already using positional argument. 207 00:12:33,630 --> 00:12:35,910 So here this is my argument. 208 00:12:35,910 --> 00:12:37,260 No argument, No. 209 00:12:37,260 --> 00:12:37,650 One. 210 00:12:37,650 --> 00:12:39,040 Argument number two. 211 00:12:39,070 --> 00:12:42,490 So the positional arguments, the numbering will be something like this. 212 00:12:42,780 --> 00:12:46,640 So he had mentioned in the argument, but no here. 213 00:12:46,920 --> 00:12:47,700 So that is up. 214 00:12:48,210 --> 00:12:50,220 So one means today will be coming down. 215 00:12:50,230 --> 00:12:56,070 So zero minutes is will be coming down here and sun will be coming down to this particular placeholder 216 00:12:56,340 --> 00:12:57,060 during the hour. 217 00:12:57,240 --> 00:13:03,870 So you can find that today is and Sunday so ordered using keyword argument. 218 00:13:03,880 --> 00:13:10,940 So here you can mention this one I as is to is d as is equal to today and this is equal to Sun. 219 00:13:10,950 --> 00:13:15,170 So here you are mentioning the respective keyword arguments there. 220 00:13:15,360 --> 00:13:19,610 So there is DS and we are getting the output count output like this one. 221 00:13:19,920 --> 00:13:21,990 So that is another way to print our string. 222 00:13:24,450 --> 00:13:25,570 Formatting numbers. 223 00:13:26,040 --> 00:13:31,370 So here to see where having this format 20 20 is only one argument is there? 224 00:13:31,380 --> 00:13:33,640 So it is argument position number is zero. 225 00:13:33,990 --> 00:13:38,280 So we are printing here and here, printing zero, but in the binary format. 226 00:13:38,550 --> 00:13:43,680 So whatever the outcome in the case, so 20 will be printed along with this 20 in the binary form, 227 00:13:43,680 --> 00:13:47,120 that is 16 plus four and that is our 20. 228 00:13:47,820 --> 00:13:50,940 So now we are having this formatting float's. 229 00:13:50,940 --> 00:13:52,430 We can go for this formatting. 230 00:13:52,800 --> 00:13:54,900 So now we are having the zero that wins. 231 00:13:54,900 --> 00:14:00,140 This particular number is going to get printed and that will be printed in this EXPONENTIATION format. 232 00:14:00,960 --> 00:14:06,880 And now we are having this one by three and we're going to bring this one, this argument number, Giteau 233 00:14:07,170 --> 00:14:08,210 and then Kolon. 234 00:14:09,000 --> 00:14:11,160 That is that decimal point 3F. 235 00:14:11,400 --> 00:14:16,290 So after the decimal point will be going to have about three decimal digits. 236 00:14:17,410 --> 00:14:24,060 But having this particular strings and having the string method, there is a lot apart find and we are 237 00:14:24,060 --> 00:14:29,700 having the plus Soyinka's look at all the string characters will be converted to the lowercase in case 238 00:14:29,700 --> 00:14:34,530 of apart, all the string characters will be converted to the uppercase irrespective of the initial 239 00:14:34,530 --> 00:14:35,060 case here. 240 00:14:35,490 --> 00:14:36,610 So find two. 241 00:14:36,930 --> 00:14:40,190 So these two will be found at the 13th index. 242 00:14:40,200 --> 00:14:41,470 So let me go on counting here. 243 00:14:41,790 --> 00:14:47,140 So that is about one, two, three, four, five, six, seven, eight, nine, 10, 11, 12. 244 00:14:47,820 --> 00:14:50,610 And from the 13 index, these two is beginning. 245 00:14:50,670 --> 00:14:52,790 So that's why I'm getting here 13. 246 00:14:53,190 --> 00:14:59,400 But if you go on searching this to all this DNA in the lowercase, we may not get a match because it 247 00:14:59,400 --> 00:15:01,360 is a sensitive find. 248 00:15:01,590 --> 00:15:06,720 So as a result of that, it will give me the outcome as a minus one means unsuccessful searching. 249 00:15:07,230 --> 00:15:13,770 So replace all by everybody and it plus all by everybody know heresy there that if you consider the 250 00:15:13,770 --> 00:15:18,330 case insensitivities, if you are getting a match, so all will be replaced by everybody. 251 00:15:18,330 --> 00:15:19,050 But here it is. 252 00:15:19,050 --> 00:15:24,320 All is written all in lowercase, so hll so everybody cannot replace it. 253 00:15:24,510 --> 00:15:29,130 So because that is not a no match has been observed using this replace method. 254 00:15:29,520 --> 00:15:34,500 So in this way we have discussed that how to operate the string and what are the different string methods 255 00:15:34,500 --> 00:15:37,500 and operations can be carried out in this session. 256 00:15:37,890 --> 00:15:39,090 Thanks for watching this video.