1 00:00:00,000 --> 00:00:01,466 [No audio] 2 00:00:01,467 --> 00:00:02,612 In this video, you will 3 00:00:02,613 --> 00:00:05,754 become more familiar with lists. 4 00:00:05,755 --> 00:00:11,236 So previously we stored three float data types in a list. 5 00:00:11,237 --> 00:00:15,316 But you can store any type of object, not only 6 00:00:15,317 --> 00:00:20,324 floats. So we can store an integer such as 9. 7 00:00:20,325 --> 00:00:23,680 You can store a string such as Hello. 8 00:00:24,210 --> 00:00:28,668 You can even store lists inside a list. 9 00:00:28,669 --> 00:00:31,052 You just write the square brackets and 10 00:00:31,053 --> 00:00:35,160 then enter the items of that list. 11 00:00:36,810 --> 00:00:40,182 So still, this list has three items. 12 00:00:40,183 --> 00:00:43,180 This integer, this string, and this list. 13 00:00:44,110 --> 00:00:47,296 And of course, you can print out that list 14 00:00:47,297 --> 00:00:50,720 by pointing to the variable associated with the list. 15 00:00:50,721 --> 00:00:52,699 [No audio] 16 00:00:52,699 --> 00:00:54,836 And that's the output that we get. 17 00:00:54,837 --> 00:00:58,090 Now, Math operations with lists, 18 00:00:58,091 --> 00:01:00,292 what does list support? 19 00:01:00,293 --> 00:01:02,630 Well, not much really. 20 00:01:02,631 --> 00:01:03,936 You can do 21 00:01:03,937 --> 00:01:06,200 [No audio] 22 00:01:06,201 --> 00:01:09,600 multiplications with an integer such as 2 23 00:01:09,600 --> 00:01:12,040 or 3, and let's see what's going to happen. 24 00:01:12,041 --> 00:01:15,182 So I'm going to print out that expression directly 25 00:01:15,183 --> 00:01:18,434 here instead of putting that in a variable. 26 00:01:18,435 --> 00:01:20,732 So whatever you prefer, you can create a new 27 00:01:20,733 --> 00:01:24,652 variable, store that in the variable, and then place 28 00:01:24,653 --> 00:01:27,580 the variable in the print function, or directly place 29 00:01:27,581 --> 00:01:29,872 this expression in the print function. 30 00:01:29,873 --> 00:01:30,960 Both will work. 31 00:01:30,961 --> 00:01:35,696 So if you run that, you're going to get this 32 00:01:35,697 --> 00:01:42,240 output. So that the same list repeated three times. 33 00:01:43,810 --> 00:01:47,818 If this was plus, this is not supported because Python doesn't 34 00:01:47,819 --> 00:01:52,522 know what to do with a list and an integer. 35 00:01:52,523 --> 00:01:56,206 So it gives you an error, TypeError only can concatenate 36 00:01:56,207 --> 00:02:02,126 lists to lists, so it can concatenate lists to lists. 37 00:02:02,127 --> 00:02:04,376 So if you do student_grades plus 38 00:02:04,377 --> 00:02:07,370 student_grades, that will also work. 39 00:02:07,371 --> 00:02:10,940 So run that and you get this result. 40 00:02:10,941 --> 00:02:14,588 So the list repeated two times, which 41 00:02:14,589 --> 00:02:18,460 is the equivalent of that times two. 42 00:02:19,390 --> 00:02:20,848 So again, we're going to get 43 00:02:20,849 --> 00:02:23,580 the same results, here and there. 44 00:02:24,830 --> 00:02:28,950 Lastly, there's also a way to auto generate 45 00:02:28,951 --> 00:02:34,052 lists of integers that have a certain order. 46 00:02:34,053 --> 00:02:36,052 Let's say you want to have a 47 00:02:36,053 --> 00:02:40,836 list from 1 to 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. 48 00:02:40,837 --> 00:02:42,320 How can we do that? 49 00:02:42,850 --> 00:02:46,728 Well, of course one way is to write that down, but there 50 00:02:46,729 --> 00:02:49,890 is a better way, and that is to use a range. 51 00:02:51,030 --> 00:02:54,472 range is another type of object. 52 00:02:54,473 --> 00:02:58,730 Just like we have lists, integers, we also have ranges. 53 00:02:58,731 --> 00:03:02,490 So range 0 and 11. 54 00:03:02,491 --> 00:03:06,332 And let's run student_grades to see what 55 00:03:06,333 --> 00:03:09,328 this variable has now as a value. 56 00:03:09,329 --> 00:03:13,232 So run that and this is a range object. 57 00:03:13,233 --> 00:03:15,968 So not much to see yet, but if 58 00:03:15,969 --> 00:03:20,898 you convert this into a list and run again, 59 00:03:20,900 --> 00:03:23,666 [No audio] 60 00:03:23,667 --> 00:03:25,722 lastly we're going to get that output. 61 00:03:25,723 --> 00:03:28,852 So 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. 62 00:03:28,853 --> 00:03:32,260 So now student_grades is a list object 63 00:03:32,261 --> 00:03:35,860 and this list keyword here is a class. 64 00:03:36,390 --> 00:03:41,112 So it represents the list data type, and it is 65 00:03:41,113 --> 00:03:45,512 used here to convert a range data type into a 66 00:03:45,513 --> 00:03:50,412 list data type, because a range displays simply like this. 67 00:03:50,413 --> 00:03:53,160 So this is not very beneficial to see. 68 00:03:53,690 --> 00:03:55,708 The output is not so clear, so we 69 00:03:55,709 --> 00:03:57,660 convert it into a list data type. 70 00:03:57,661 --> 00:04:00,080 And so how does it work? 71 00:04:00,081 --> 00:04:03,952 Well, it starts from 0 up to the 72 00:04:03,953 --> 00:04:06,576 number before this number, which is 10. 73 00:04:06,577 --> 00:04:07,808 So 0 to 10. 74 00:04:07,809 --> 00:04:10,190 That's why we have 0 to 10. 75 00:04:10,191 --> 00:04:12,324 Of course, you can have anything here. 76 00:04:12,325 --> 00:04:14,948 So 1 to 8, I would have to 77 00:04:14,949 --> 00:04:17,684 write 9 to get 1 to 8, 78 00:04:17,685 --> 00:04:20,079 so it'll list 1 to 8. 79 00:04:21,089 --> 00:04:27,272 You can also have another argument here, two, and 80 00:04:27,273 --> 00:04:30,130 let's see what that changes in the output. 81 00:04:30,131 --> 00:04:33,566 [No audio] 82 00:04:33,580 --> 00:04:38,090 So we get these results, that 2 is the step. 83 00:04:38,700 --> 00:04:43,362 So 1, 3, 5, 7, it means that you start from 1 84 00:04:43,363 --> 00:04:45,522 and then you move by a step of 2. 85 00:04:45,523 --> 00:04:48,002 So 1 plus 2, you have 3. 86 00:04:48,003 --> 00:04:49,634 3 plus 2, you have 5. 87 00:04:49,635 --> 00:04:51,154 5 plus 2, you have 7. 88 00:04:51,155 --> 00:04:52,850 7 plus 2, you have 9, 89 00:04:52,851 --> 00:04:56,360 but 9 is not included in the range. 90 00:04:56,361 --> 00:04:59,440 The range is up to 8, so 91 00:04:59,441 --> 00:05:01,790 the list will end up at 7. 92 00:05:02,440 --> 00:05:05,642 Of course, you can have any steps here, 93 00:05:05,643 --> 00:05:08,768 like 3, and you'll get different results. 94 00:05:08,769 --> 00:05:10,592 So that was some more advanced 95 00:05:10,593 --> 00:05:14,840 information about lists and also ranges. 96 00:05:14,841 --> 00:05:16,544 With that, I thank you and I'll 97 00:05:16,545 --> 00:05:18,033 talk to you in the next video. See you there.