1 00:00:11,750 --> 00:00:17,840 Hello, everybody, and welcome to the practice, they are offset collections, so please open your 2 00:00:17,840 --> 00:00:20,540 project, Invitrogen, which is learning. 3 00:00:21,000 --> 00:00:23,180 All right, just opening right now. 4 00:00:25,340 --> 00:00:26,410 All right. 5 00:00:26,420 --> 00:00:32,870 And then create a new file with a substantial name collections. 6 00:00:34,620 --> 00:00:44,070 SAT practice, all right, first of all, as always, let's leave a meaningful comment for the future. 7 00:00:44,220 --> 00:00:44,640 All right. 8 00:00:44,670 --> 00:00:48,510 So that's Data-Collection set. 9 00:00:49,700 --> 00:00:50,280 Practice. 10 00:00:51,240 --> 00:00:58,490 All right, so first of all, I ask you guys to create a collection of drinks, so let's do that. 11 00:00:59,000 --> 00:01:05,270 So first mission is to create a new set. 12 00:01:07,290 --> 00:01:09,770 Collection of drinks, right? 13 00:01:10,350 --> 00:01:20,310 So it goes like this, drinks curly brackets and then inside quotation marks with both the items as 14 00:01:20,310 --> 00:01:27,240 we learned in the previous lecture, then we have Sprite and then we have. 15 00:01:29,810 --> 00:01:30,410 Beer. 16 00:01:30,800 --> 00:01:38,940 All right, so just be careful, because beer is for 18 plus age, at least in my country. 17 00:01:39,770 --> 00:01:41,600 And now we have water. 18 00:01:43,460 --> 00:01:45,260 And now we have. 19 00:01:48,110 --> 00:01:48,680 Soda. 20 00:01:49,100 --> 00:01:56,930 All right, so like that, and then I asked you to add additional sale containing soda value. 21 00:01:57,520 --> 00:01:58,000 All right. 22 00:01:58,250 --> 00:02:09,230 As you recall, we had like a note here that if you had another sale of soda, we already have soda 23 00:02:09,230 --> 00:02:10,030 sale right here. 24 00:02:10,370 --> 00:02:14,390 So it would be a duplicate and set does not like duplicates. 25 00:02:14,780 --> 00:02:15,220 Right. 26 00:02:15,230 --> 00:02:18,310 But with that said, let's add it. 27 00:02:19,730 --> 00:02:20,070 All right. 28 00:02:20,120 --> 00:02:24,480 Add additional sale with soda value. 29 00:02:25,100 --> 00:02:26,480 So how do we do it? 30 00:02:26,540 --> 00:02:33,530 We just mention the asset collection then that then we have all these options open up for us. 31 00:02:33,530 --> 00:02:38,470 And by chance and we just want to add here a new item. 32 00:02:38,510 --> 00:02:40,520 So we just choose this one. 33 00:02:40,520 --> 00:02:46,130 Add sorry, and we use we choose the add one and the inside here. 34 00:02:46,130 --> 00:02:47,480 We just add whatever we want. 35 00:02:47,720 --> 00:02:54,620 In our case we add soda and after we added soda, let's try to print that print or even go. 36 00:02:54,830 --> 00:02:56,900 By the way, I forgot to print here. 37 00:02:56,960 --> 00:02:57,410 All right. 38 00:02:58,490 --> 00:02:59,030 Said. 39 00:03:02,180 --> 00:03:04,400 Collection brings out. 40 00:03:07,130 --> 00:03:08,330 Right, casting. 41 00:03:10,190 --> 00:03:20,450 And drinks I so want and output for all of our actions, this would be Simon number one, this would 42 00:03:20,450 --> 00:03:23,750 be assignment number two like that. 43 00:03:26,140 --> 00:03:30,900 And printing green. 44 00:03:31,920 --> 00:03:35,010 Printing drinks. 45 00:03:36,220 --> 00:03:37,750 After adding. 46 00:03:39,750 --> 00:03:43,650 An additional solar cell like that. 47 00:03:43,710 --> 00:03:44,070 All right. 48 00:03:46,390 --> 00:03:52,590 So now we do the casting, then drinks, and once we do it, anyone can tell what will happen. 49 00:03:52,930 --> 00:03:58,920 We said that Seth Collection does not like duplicates, so let's try to print it and see what happens. 50 00:04:00,870 --> 00:04:07,680 OK, so this is the first one we see over water, cola, soda and Sprite, and here we see beer, water, 51 00:04:07,680 --> 00:04:08,950 cola and Sprite. 52 00:04:09,450 --> 00:04:11,990 So what what just happened for us? 53 00:04:12,360 --> 00:04:13,200 Nothing happened. 54 00:04:13,290 --> 00:04:21,540 Nothing, because once we use the add action key correction identified that we already have this soda 55 00:04:21,540 --> 00:04:26,930 item inside our collection and it just did not edit at all to our collection. 56 00:04:27,240 --> 00:04:28,820 So this is an important point. 57 00:04:28,830 --> 00:04:35,520 If someone asks you what will happen to a cell collection, if you add additional sale with the value, 58 00:04:35,550 --> 00:04:38,360 with a value that already exist inside the collection. 59 00:04:38,400 --> 00:04:40,650 So your answer would be nothing. 60 00:04:40,860 --> 00:04:41,850 Nothing will happen. 61 00:04:42,300 --> 00:04:42,780 All right. 62 00:04:43,740 --> 00:04:46,800 So after this, we had assignment number three. 63 00:04:47,820 --> 00:04:55,040 And on assignment number three, we had to delete soda out of the set collection. 64 00:04:55,170 --> 00:04:55,560 All right. 65 00:04:55,560 --> 00:04:56,610 So how do we do it? 66 00:04:56,640 --> 00:04:58,280 We just mentioned the collection. 67 00:04:58,590 --> 00:05:07,230 Then we put the dot and now we have all the actions and we just choose a remove here and we inside quotation 68 00:05:07,230 --> 00:05:07,470 mark. 69 00:05:07,470 --> 00:05:09,030 We just mentioned what we want to delete. 70 00:05:09,150 --> 00:05:10,770 In our case, it is soda. 71 00:05:10,980 --> 00:05:12,810 And then let's just try to. 72 00:05:15,610 --> 00:05:17,470 Brent drinks. 73 00:05:18,510 --> 00:05:21,450 After deleting solar cell. 74 00:05:22,170 --> 00:05:27,660 All right, so it's right here and Los. 75 00:05:30,820 --> 00:05:39,770 Plus, SDR drinks and just Clow or so, then just close it, the brackets sprinted. 76 00:05:40,270 --> 00:05:41,650 See what happens right here. 77 00:05:42,550 --> 00:05:46,960 All right, so we have deleted the soda out of the collection. 78 00:05:46,970 --> 00:05:55,300 So as you can see, this also indicates that once we try to add here additional sale, it was not like 79 00:05:55,540 --> 00:05:59,290 invisibly added because we already have one. 80 00:05:59,300 --> 00:06:01,240 So it's like added what we can see it. 81 00:06:01,240 --> 00:06:02,780 It was not added at all. 82 00:06:02,800 --> 00:06:03,960 And why am I seeing it? 83 00:06:04,330 --> 00:06:08,880 Because right here, when we delete it so that we do not see it. 84 00:06:08,890 --> 00:06:09,550 All right. 85 00:06:09,560 --> 00:06:17,110 So again, it's just it's just strongs the fact that it was not added at all. 86 00:06:17,550 --> 00:06:19,240 OK, all right. 87 00:06:19,240 --> 00:06:25,570 So and the third assignment, we just deleted the solar cell out of the collection and now we do not 88 00:06:25,570 --> 00:06:26,020 have it. 89 00:06:27,550 --> 00:06:36,800 And anyone can recall if said collection before we go to the next assignment, which is which is copying. 90 00:06:37,450 --> 00:06:38,630 So that collection. 91 00:06:38,920 --> 00:06:39,270 All right. 92 00:06:39,280 --> 00:06:42,040 Copy said copy the. 93 00:06:44,270 --> 00:06:54,740 The drinks into a new SAT collection, so anyone remembers if a collection is an ordered or unordered 94 00:06:55,340 --> 00:06:58,080 collection and this is important for anyone to remember. 95 00:06:58,970 --> 00:06:59,260 All right. 96 00:06:59,300 --> 00:07:04,760 So if if you recall from previous lectures, we mentioned the differences between the collections and 97 00:07:04,770 --> 00:07:13,520 we mentioned that collection is an unordered collection, meaning it does not have indexes for its sales. 98 00:07:13,790 --> 00:07:17,440 So it's unordered and unindexed, it's not indexed. 99 00:07:17,930 --> 00:07:21,080 So once you try to copy it, let's see what happens. 100 00:07:21,110 --> 00:07:27,980 So you were asked to create rings to collection and copy from the existing one? 101 00:07:28,010 --> 00:07:29,750 Same as we did in list. 102 00:07:29,750 --> 00:07:34,130 If I recall, we already did this copy action. 103 00:07:34,360 --> 00:07:34,610 Right? 104 00:07:34,720 --> 00:07:35,990 So we did this like this. 105 00:07:36,650 --> 00:07:46,630 And let's try to print drinks to all print drinks to set collection. 106 00:07:47,300 --> 00:07:47,910 All right. 107 00:07:47,930 --> 00:07:55,010 And what do you think before you apply this action, can you tell me when you can you tell yourself 108 00:07:55,040 --> 00:07:58,890 to be more accurate and what would happen when we print it? 109 00:07:58,930 --> 00:07:59,240 All right. 110 00:07:59,540 --> 00:08:02,240 So here we see this order. 111 00:08:02,250 --> 00:08:05,150 We see color first and we're inspired then water. 112 00:08:05,450 --> 00:08:11,180 But as I just mentioned, the collection is an unordered and an index collection. 113 00:08:11,190 --> 00:08:18,870 So once I copy it, the important question should be, will it be copied with the same order? 114 00:08:20,030 --> 00:08:26,810 And to answer that question, you need to ask yourselves, is it an ordered collection or is it not? 115 00:08:26,900 --> 00:08:28,560 And we just said that it's not. 116 00:08:29,120 --> 00:08:31,380 So once we print it, let's see what happens. 117 00:08:32,990 --> 00:08:33,290 All right. 118 00:08:33,290 --> 00:08:34,400 As you can see here. 119 00:08:34,880 --> 00:08:35,410 All right. 120 00:08:35,420 --> 00:08:43,310 As you can see and as expected, it was not printed out in the order of what we had in the original 121 00:08:43,310 --> 00:08:45,760 drinks collection because it's an unordered list. 122 00:08:45,770 --> 00:08:52,030 So once we copy it, we're not we cannot be sure that the order will be saved. 123 00:08:52,310 --> 00:08:54,860 It's not going to be safe because it does not have indexes. 124 00:08:54,990 --> 00:09:03,230 So once you copy it in hell is going to break through like chaos because you cannot maintain order in 125 00:09:03,230 --> 00:09:04,030 a collection. 126 00:09:04,040 --> 00:09:08,120 So once you copy it, the order will be break braked. 127 00:09:08,330 --> 00:09:15,470 As you can see here, it's really important part because it's it's like when you tried to use when you 128 00:09:15,470 --> 00:09:21,830 tried to figure out which collection you want to use in your code, you have to take this in in consideration 129 00:09:21,860 --> 00:09:27,200 like you need the index or you don't need index, because sometimes you like to copy your collection 130 00:09:27,920 --> 00:09:32,810 and it's important for you to maintain the order, but sometimes it's not important for you. 131 00:09:32,840 --> 00:09:38,510 So in this case, if you use a copy of a collection, your order will be broken. 132 00:09:39,530 --> 00:09:40,540 It's very important. 133 00:09:40,550 --> 00:09:42,560 I'm trying to bring you to the A game. 134 00:09:42,560 --> 00:09:48,290 I'm trying to bring out the ninja developer out of you mentioning all these little comments that are 135 00:09:48,290 --> 00:09:49,230 very important. 136 00:09:49,250 --> 00:09:49,580 All right. 137 00:09:49,780 --> 00:09:53,300 It's like a simple, simple topic or it's just an additional collection. 138 00:09:53,540 --> 00:09:53,990 All right. 139 00:09:54,000 --> 00:09:57,200 So it doesn't it cannot contain duplicates and stuff. 140 00:09:57,440 --> 00:10:02,470 Yeah, but you have important, important things here that you might be asked in interviews. 141 00:10:02,480 --> 00:10:09,020 And furthermore, when you try when you start coding in your job, once you apply to an already accepted, 142 00:10:09,920 --> 00:10:14,840 you will try to choose a collection for your code, for a mission that you have. 143 00:10:15,050 --> 00:10:22,280 And you need to know these things because this is what differentiates medius mediocre from a ninja or 144 00:10:22,400 --> 00:10:23,410 these little things. 145 00:10:24,020 --> 00:10:28,560 So I'm trying to bring you all the little notes so you will become a professional by the end. 146 00:10:28,580 --> 00:10:28,850 All right. 147 00:10:30,080 --> 00:10:32,720 OK, so now let's go to the fifth assignment. 148 00:10:32,730 --> 00:10:36,220 So your fifth assignment was to print out. 149 00:10:36,410 --> 00:10:37,880 It was a bonus one, by the way. 150 00:10:37,880 --> 00:10:41,480 It was to print the length of the collection. 151 00:10:42,670 --> 00:10:46,720 And as I recall, I mentioned that you need to look it up online. 152 00:10:47,000 --> 00:10:49,520 So it was pretty it's pretty easy to find it. 153 00:10:49,520 --> 00:10:52,310 And I'm just going to give you the answer straight away. 154 00:10:52,550 --> 00:10:59,450 And you just need to you just need to look online how to print the length of a collection. 155 00:10:59,660 --> 00:11:05,120 And the first results will probably give you this, the following result, because you only have one 156 00:11:05,120 --> 00:11:06,230 result for this question. 157 00:11:06,240 --> 00:11:11,540 So look out for like look for the result right now. 158 00:11:11,570 --> 00:11:11,830 All right. 159 00:11:11,840 --> 00:11:14,750 So the length of the collection. 160 00:11:15,820 --> 00:11:22,360 Drinks is is on is, yeah, so what do you do? 161 00:11:22,390 --> 00:11:30,100 So, first of all, there is the key action guyland at the end like that, and then inside you put the 162 00:11:30,120 --> 00:11:32,740 collection that you want, the length of it be print it out. 163 00:11:33,070 --> 00:11:38,680 But now we have here, all right, here we have a integer and this is a string. 164 00:11:39,460 --> 00:11:40,480 So we have a problem. 165 00:11:40,480 --> 00:11:46,650 So we need to cover it with, uh, with a casting for strings. 166 00:11:50,060 --> 00:11:52,800 So we have string, you have length and you have drinks. 167 00:11:53,300 --> 00:11:56,300 All right, let's sprint, let's see what happens. 168 00:11:57,290 --> 00:11:59,680 OK, so we have four cells here. 169 00:11:59,690 --> 00:12:04,480 One is the copy one this one, one, two, three, four. 170 00:12:04,880 --> 00:12:10,570 If I recall, we already use the length and once we studied the lists. 171 00:12:10,670 --> 00:12:11,060 All right. 172 00:12:11,060 --> 00:12:14,390 So we use it already is just a reminder of how to do it. 173 00:12:14,630 --> 00:12:16,410 But again, all right. 174 00:12:16,550 --> 00:12:17,450 This is how you do it. 175 00:12:17,450 --> 00:12:24,050 Just put langue action and inside you put the lay of what you think of what you need to recall. 176 00:12:24,350 --> 00:12:27,890 And around it, you put the casting of string like that. 177 00:12:28,400 --> 00:12:30,290 So you have the number four here. 178 00:12:30,440 --> 00:12:34,560 And actually you have four cells here, one, two, three, four. 179 00:12:34,580 --> 00:12:38,090 So this one is also correct and this is about it. 180 00:12:38,450 --> 00:12:44,120 I think we covered everything that we need to know regarding said collections. 181 00:12:44,320 --> 00:12:44,630 Right. 182 00:12:44,630 --> 00:12:47,240 We practice it here and learn learned lot things. 183 00:12:47,420 --> 00:12:53,420 So we learned that once we add a cell that already exists inside the cell collection, it's not going 184 00:12:53,420 --> 00:12:56,810 to be added like the cold is going to just completely ignore of it. 185 00:12:57,650 --> 00:13:05,000 And after that, when we copied it and we tried to print out the copy, we have seen that chaos goes 186 00:13:05,000 --> 00:13:12,210 goes up because we cannot maintain order in an unindexed collection such such as set. 187 00:13:12,540 --> 00:13:17,420 So once we printed out the drinks, too, did not maintain the order. 188 00:13:17,720 --> 00:13:24,620 And last we had to print out the length of the collection and we saw that we printed out the number 189 00:13:24,620 --> 00:13:26,640 of items that we have successfully. 190 00:13:26,930 --> 00:13:27,290 All right. 191 00:13:27,320 --> 00:13:28,500 So this is about it. 192 00:13:28,640 --> 00:13:36,020 So in the next lecture, we will learn about tuple, which our fourth collection, fourth and last collection. 193 00:13:36,320 --> 00:13:44,430 And once we complete that part, we will be masters in collections and in interviews we can ask you 194 00:13:44,540 --> 00:13:46,190 we can be asked for everything. 195 00:13:46,190 --> 00:13:49,430 And I assure you that you will know all the answers. 196 00:13:49,640 --> 00:13:55,640 If you watched all the theory lectures and practiced all the assignments, I'm sure that you can answer 197 00:13:55,820 --> 00:13:58,100 every question that anyone would ask you. 198 00:13:58,490 --> 00:14:01,080 And that's about it for this lecture. 199 00:14:01,100 --> 00:14:03,190 See you in the next video regarding Topal. 200 00:14:03,590 --> 00:14:04,670 Thank you and bye bye.