1 00:00:12,220 --> 00:00:18,730 Hello, so and this video will resolve last videos assignments, so once you open your project, just 2 00:00:18,730 --> 00:00:24,400 create a new file, give it an indicative name, for example, collections. 3 00:00:25,300 --> 00:00:25,870 List. 4 00:00:27,560 --> 00:00:30,640 And then practice basics. 5 00:00:31,850 --> 00:00:34,940 Let's give a nice comment, basically the same one. 6 00:00:45,120 --> 00:00:52,890 And all right, so first of all, I asked you guys to create a new list, so just declare a name and 7 00:00:52,890 --> 00:00:54,050 then put the equal mark. 8 00:00:54,450 --> 00:01:00,840 And once you do that, you see Python does not know if it's a variable of its own or if it's a list 9 00:01:00,840 --> 00:01:02,310 or he doesn't know what it is. 10 00:01:02,670 --> 00:01:08,640 But once you apply the square brackets, he immediately removes the red area from below and he knows 11 00:01:08,640 --> 00:01:10,530 that this is a list. 12 00:01:10,860 --> 00:01:16,010 So add and then a car brands into the list, so their names. 13 00:01:16,020 --> 00:01:23,100 So we have to put quotation marks and let's start off with BMW and then it Colma dividing it and then 14 00:01:23,100 --> 00:01:23,790 Toyota 15 00:01:26,190 --> 00:01:30,420 and then we have Dassler and Kiya. 16 00:01:34,110 --> 00:01:41,280 Do you have closing quotation marks here and also, let's see, a small thing, what happens if I remove 17 00:01:41,280 --> 00:01:47,940 the quotation marks by Chami immediately sets a red line B below the text and Southeastern error, and 18 00:01:48,390 --> 00:01:50,040 he has some trouble with it. 19 00:01:50,880 --> 00:01:51,360 All right. 20 00:01:51,360 --> 00:01:56,220 So let's print it out print and the indicative comment. 21 00:01:59,870 --> 00:02:04,820 All right, and then put outside quotation marks, the glass. 22 00:02:07,230 --> 00:02:09,390 Then do the casting into a string. 23 00:02:09,900 --> 00:02:13,290 All right, we all remember a whole pie chart was angry. 24 00:02:13,290 --> 00:02:14,570 We were not casting. 25 00:02:14,580 --> 00:02:18,810 So here we have a string and here we have a list. 26 00:02:19,080 --> 00:02:26,100 So by Trump does not like two types of data types inside the print, so we need to cast it for all of 27 00:02:26,100 --> 00:02:29,370 it will be a string that's trying to run it. 28 00:02:30,750 --> 00:02:31,710 And there we have it. 29 00:02:31,710 --> 00:02:34,050 We have the list printed as following. 30 00:02:35,110 --> 00:02:37,050 So let's head over to the next assignment. 31 00:02:37,050 --> 00:02:38,190 Just print out. 32 00:02:41,190 --> 00:02:45,240 That one before last, I last them. 33 00:02:47,260 --> 00:02:51,140 Out of cars list and how do we do it? 34 00:02:51,490 --> 00:02:58,750 So, first of all, declare the list cars and then if you remember, when we want the last item, we 35 00:02:58,750 --> 00:02:59,920 put minus one here. 36 00:02:59,950 --> 00:03:01,900 This is the last item on the off the list. 37 00:03:02,140 --> 00:03:03,910 But we want one before last. 38 00:03:03,910 --> 00:03:06,820 So we go one lower minus two. 39 00:03:07,150 --> 00:03:09,630 Basically what we want to print out is Destler. 40 00:03:09,910 --> 00:03:12,250 So let's try to print it. 41 00:03:14,660 --> 00:03:15,440 All right. 42 00:03:18,440 --> 00:03:27,680 And right here had a comment and a comment, one before last night off the list. 43 00:03:30,210 --> 00:03:41,370 Plus casting and close it and also, guys, you see when you put your cursor near the brackets, you 44 00:03:41,370 --> 00:03:44,050 can see the sibling brackets is marked for you. 45 00:03:44,340 --> 00:03:49,380 So if you get confused, if you're having too many brackets, so you always, always can see who the 46 00:03:49,380 --> 00:03:51,740 sibling bracket, LAMARTINE Yellow. 47 00:03:52,260 --> 00:03:52,820 All right. 48 00:03:52,830 --> 00:03:53,810 And this one as well. 49 00:03:54,720 --> 00:03:56,040 All right, let's try to run it. 50 00:03:58,710 --> 00:03:59,070 Great. 51 00:03:59,100 --> 00:04:01,940 So we have Dassler printed out exactly what we wanted. 52 00:04:02,760 --> 00:04:09,960 Let's head over to the next assignment and compare it like something happening here in COMPAR. 53 00:04:11,550 --> 00:04:13,140 Uh, compare. 54 00:04:16,360 --> 00:04:21,820 Lists item on index one to. 55 00:04:24,040 --> 00:04:26,690 Toyota strength. 56 00:04:27,460 --> 00:04:30,310 So we want to pull out from cars. 57 00:04:31,970 --> 00:04:40,940 The value from one and use a comparison operator double equals sign and to compare it to a simple string, 58 00:04:40,970 --> 00:04:44,410 which is quotation marks, Toyota like that. 59 00:04:44,810 --> 00:04:49,820 So all of that needs to be covered with a print. 60 00:04:51,580 --> 00:04:52,430 All right. 61 00:04:52,820 --> 00:05:05,510 So closing in, that's an indicative comment about comparison between zero one. 62 00:05:07,490 --> 00:05:08,480 From cars. 63 00:05:09,660 --> 00:05:10,170 To. 64 00:05:12,080 --> 00:05:12,680 Toyota. 65 00:05:18,110 --> 00:05:24,830 And then close quotation Mark Glass and casting is always to a. 66 00:05:26,390 --> 00:05:28,910 So I just want to hold on here for a second. 67 00:05:29,390 --> 00:05:33,800 You might notice that our print actions used to be really simple. 68 00:05:33,800 --> 00:05:37,970 We just added a simple string and then a variable, and that's it. 69 00:05:38,330 --> 00:05:41,600 But here we are already trying to print out manipulations. 70 00:05:41,600 --> 00:05:46,010 So like actions taken inside the print. 71 00:05:46,280 --> 00:05:47,260 And here we are. 72 00:05:47,570 --> 00:05:50,600 We have also a comparison operator inside it. 73 00:05:50,840 --> 00:05:54,830 So it's not as simple as it was before because we have some complications here. 74 00:05:54,830 --> 00:05:59,870 We have some calculations and but it's the same the same principle. 75 00:06:00,170 --> 00:06:05,660 Like if you want to add a comment, just add it in quotation marks and then add a plus and cast whatever 76 00:06:05,660 --> 00:06:08,890 you want inside of records and it will be printed up. 77 00:06:09,260 --> 00:06:10,610 So let's check this out. 78 00:06:10,760 --> 00:06:18,040 By the way, what value are we expecting once we're applying a comparison operator? 79 00:06:18,080 --> 00:06:23,170 So we're expecting a boolean variable rate, a true or false value as we study. 80 00:06:23,180 --> 00:06:24,260 So let's try to print it. 81 00:06:25,520 --> 00:06:25,780 Great. 82 00:06:25,910 --> 00:06:28,160 So we got what we want here. 83 00:06:28,160 --> 00:06:35,090 We compare the Toyota from inside the list and we compare that with Toyota's simple string and we got 84 00:06:35,090 --> 00:06:35,860 a true value. 85 00:06:36,080 --> 00:06:40,940 Let's try to change it to N equals with an exclamation mark, an equal saying. 86 00:06:41,330 --> 00:06:50,090 And when we run this one, so we get a false because we asked whether Toyota and Toyota are not equal. 87 00:06:50,420 --> 00:06:52,250 And this is a false statement. 88 00:06:54,240 --> 00:06:58,140 All right, so let's head over to the next one. 89 00:06:58,170 --> 00:07:02,640 So now we would like to create a new list called. 90 00:07:05,270 --> 00:07:08,180 Mixed values, right? 91 00:07:08,870 --> 00:07:10,580 So we have the mixed values. 92 00:07:13,370 --> 00:07:17,840 And we want to put some values in it, so first one in line is Jim, so give us a name. 93 00:07:17,850 --> 00:07:22,330 So we have to put quotation marks in order to indicate that this is a string variable inside the list. 94 00:07:22,610 --> 00:07:23,920 And this one is a number. 95 00:07:23,930 --> 00:07:26,270 So no quotation marks needed. 96 00:07:27,110 --> 00:07:29,780 Next one is Alex, which is also a string. 97 00:07:30,500 --> 00:07:37,340 And then we have to dot five three, which is a float, also a number of quotation marks. 98 00:07:37,580 --> 00:07:42,200 And last but not least, we have the boolean variable, which is true. 99 00:07:43,160 --> 00:07:44,700 And there you go. 100 00:07:45,290 --> 00:07:54,020 So we have a list that makes one that contains string and float and boolean, and that's great. 101 00:07:54,050 --> 00:07:58,100 So we have lots of types here and now. 102 00:07:58,100 --> 00:08:00,620 Once we have it, let's try to printout. 103 00:08:02,480 --> 00:08:04,400 First of all, we want to print. 104 00:08:06,530 --> 00:08:09,610 Bring the list, makes the values. 105 00:08:12,770 --> 00:08:16,250 All right, so closing quotation marks. 106 00:08:17,840 --> 00:08:20,300 And casting and then mixed values. 107 00:08:22,150 --> 00:08:25,000 Yeah, all right, that let's try to run it. 108 00:08:27,130 --> 00:08:35,110 All right, so we printed it out and now let's do an interesting thing, let's just pull out the values 109 00:08:35,110 --> 00:08:38,170 in the sales between zero and three, including three. 110 00:08:38,770 --> 00:08:46,390 So print out the values out of mixed values. 111 00:08:47,610 --> 00:08:48,510 From the cells. 112 00:08:50,340 --> 00:08:53,490 Zero to three, including three. 113 00:08:54,580 --> 00:08:54,950 Right. 114 00:08:56,440 --> 00:08:58,360 So how do we do it? 115 00:08:59,290 --> 00:09:05,590 So we studied it in the theory part of this, which is declare the list. 116 00:09:06,130 --> 00:09:12,580 Then inside the square brackets we put the limitation and we have two dots between them like that. 117 00:09:13,120 --> 00:09:16,540 And do you remember if this is the correct answer? 118 00:09:17,380 --> 00:09:25,120 Because I think that we need to think again if we agree that this is the correct, because if anyone 119 00:09:25,120 --> 00:09:35,440 remembers, we said something about the ending of the limitation here, that this one, the third one, 120 00:09:35,470 --> 00:09:38,020 which one is the third one in the mixed values. 121 00:09:38,350 --> 00:09:38,640 All right. 122 00:09:38,650 --> 00:09:39,430 This is zero. 123 00:09:39,690 --> 00:09:40,360 This is one. 124 00:09:40,660 --> 00:09:41,320 This is two. 125 00:09:41,410 --> 00:09:42,190 And this is three. 126 00:09:42,580 --> 00:09:45,520 So let's see if this value will also be printed. 127 00:09:47,620 --> 00:09:55,330 As you can see, it's not printed, all right, so it's not printed and this causes us a trouble because 128 00:09:55,330 --> 00:09:57,220 we wanted to print this value as well. 129 00:09:58,030 --> 00:10:04,600 So what we need to do is to put number four here and then three will be included as well, which is 130 00:10:04,600 --> 00:10:06,860 to dot five three. 131 00:10:07,600 --> 00:10:09,390 So now we see it right here. 132 00:10:09,820 --> 00:10:10,200 Great. 133 00:10:10,660 --> 00:10:17,320 And let's go over to the next assignment and try to print out the value off. 134 00:10:17,320 --> 00:10:20,620 And that's six out of the mixed. 135 00:10:22,500 --> 00:10:23,160 Values. 136 00:10:24,060 --> 00:10:36,480 So when we try to print it and that's put the mixed values and square brackets six where we try to print 137 00:10:36,480 --> 00:10:40,920 it as see, we have no sixth sell in the list. 138 00:10:41,610 --> 00:10:47,610 We have cell number zero sell number one, two, three, four, and we're finished. 139 00:10:47,790 --> 00:10:52,370 So we're trying to tell the cold print of the cell number six, but we don't have it. 140 00:10:52,380 --> 00:10:57,100 So once we run it, obviously we have an error. 141 00:10:58,170 --> 00:10:58,590 All right. 142 00:10:58,890 --> 00:11:04,290 So our everything comes after this will not be executed. 143 00:11:05,100 --> 00:11:05,900 Let us check. 144 00:11:06,320 --> 00:11:13,920 Let's try to see if we can get the print of lots of X's after this one, after the error. 145 00:11:14,040 --> 00:11:14,480 All right. 146 00:11:14,880 --> 00:11:23,860 So when we try to run it, you see the exact printout did not occur because it was not executed this 147 00:11:23,880 --> 00:11:26,940 year or has blocked the running of the code. 148 00:11:27,480 --> 00:11:33,330 So basically, what we need to do now is what we discussed in assignments and assignments. 149 00:11:33,900 --> 00:11:39,570 Assignment number seven, just to mark up this line and then heat up control and backslash together. 150 00:11:39,930 --> 00:11:46,610 And you see this was edited and this one is commented out of the code. 151 00:11:46,860 --> 00:11:51,620 When we run it right now, we can see the Xs printed up. 152 00:11:51,960 --> 00:11:52,410 All right. 153 00:11:52,870 --> 00:11:56,430 And now let's go after the last assignment, which is. 154 00:11:59,240 --> 00:12:00,370 And the value. 155 00:12:03,930 --> 00:12:07,350 All federal mail to the cars. 156 00:12:08,830 --> 00:12:17,050 List, and when we want to add some items to the list, we just do the following, we just do the cars, 157 00:12:17,680 --> 00:12:22,090 declare the we call out the list and then use that. 158 00:12:22,920 --> 00:12:24,420 And we have actions here. 159 00:12:24,850 --> 00:12:26,380 So that's just the action. 160 00:12:26,510 --> 00:12:27,990 Bend it. 161 00:12:28,750 --> 00:12:34,840 And inside, because we have a string that supply quotation marks and add alpha. 162 00:12:37,600 --> 00:12:43,410 ReMail and this action adds a value to the list as the last item. 163 00:12:43,770 --> 00:12:46,140 It adds another index to the list. 164 00:12:46,530 --> 00:12:46,980 All right. 165 00:12:47,430 --> 00:12:49,340 So let's try to print it out. 166 00:12:51,030 --> 00:12:56,410 Glassless, printed after the hour of. 167 00:13:01,400 --> 00:13:06,500 All right, so let's add the cast list. 168 00:13:07,090 --> 00:13:11,210 So basically what happened is we had the cast list. 169 00:13:12,790 --> 00:13:21,130 Declared here, and it had only BMW, Toyota, Tesla and Kia, and then right here we have added another 170 00:13:21,130 --> 00:13:21,990 item to the list. 171 00:13:22,000 --> 00:13:31,270 So since this point and on so since this dot, since this moment and so on down the road, once we print 172 00:13:31,270 --> 00:13:33,700 the cars, it will be an updated list. 173 00:13:34,390 --> 00:13:34,820 All right. 174 00:13:34,840 --> 00:13:36,070 It's an updated list. 175 00:13:36,250 --> 00:13:44,080 And if we try to print it right here where the courser is right now, right here, it will be printed 176 00:13:44,080 --> 00:13:47,410 out without the alpha male because it hasn't been updated yet. 177 00:13:48,190 --> 00:13:51,370 OK, so that's casting. 178 00:13:56,280 --> 00:14:00,450 And you know what, that's out here after adding. 179 00:14:03,770 --> 00:14:10,190 We already have the after, all right, and that's the here and now the president, because I want to 180 00:14:10,190 --> 00:14:17,530 show you what what I just talked about cars list before at the of. 181 00:14:22,300 --> 00:14:27,580 So, all right, so that's the plus here, gas the cars. 182 00:14:30,430 --> 00:14:33,480 OK, so let's try to print it out. 183 00:14:37,460 --> 00:14:44,070 And there you have it, so cast list before adding Alfa Romeo, all right, which we try to print it 184 00:14:44,090 --> 00:14:48,350 right here before we apply the append action does not have Alfa Romeo. 185 00:14:48,650 --> 00:14:55,520 Once we used the append action, once we tried to bring the updated list, we can see Alfa Romeo added 186 00:14:55,520 --> 00:14:56,060 right here. 187 00:14:57,050 --> 00:14:58,520 So we're complete. 188 00:14:58,520 --> 00:15:05,690 We have completed the basics practice part of this again, don't be worry about if you did not succeed 189 00:15:05,690 --> 00:15:14,150 the last assignment, because we haven't covered it yet in the material, we will start covering this 190 00:15:14,150 --> 00:15:16,960 advanced lecture and the next video. 191 00:15:17,240 --> 00:15:18,710 So don't worry about it. 192 00:15:18,710 --> 00:15:19,510 And that's about it. 193 00:15:19,510 --> 00:15:21,620 You guys see you and the next video.