1 00:00:00,600 --> 00:00:02,050 Instructor: Hey, long time, no see. 2 00:00:02,050 --> 00:00:04,410 It's, it's been a while but I'm glad you're back 3 00:00:04,410 --> 00:00:06,750 and I'm glad you're still hanging in there. 4 00:00:06,750 --> 00:00:09,660 Trust me, things, things are going to get a lot more fun 5 00:00:09,660 --> 00:00:11,700 once we actually start building applications 6 00:00:11,700 --> 00:00:15,630 but we do have to go through the basics, so hang in there. 7 00:00:15,630 --> 00:00:18,300 Now, you may have heard me mention 8 00:00:18,300 --> 00:00:21,060 methods and functions before. 9 00:00:21,060 --> 00:00:23,730 And I briefly touched on the subject, right? 10 00:00:23,730 --> 00:00:28,110 We have functions like list, print. 11 00:00:28,110 --> 00:00:32,940 We have things like max, min, what else do we have? 12 00:00:32,940 --> 00:00:34,290 We have input, 13 00:00:34,290 --> 00:00:38,340 these are all built-in functions in Python. 14 00:00:38,340 --> 00:00:41,220 Python just comes with this and we're able to use them. 15 00:00:41,220 --> 00:00:42,990 And we also learned about functions 16 00:00:42,990 --> 00:00:44,370 that we can create ourselves. 17 00:00:44,370 --> 00:00:46,440 Custom functions like, well, 18 00:00:46,440 --> 00:00:50,670 some random stuff. 19 00:00:50,670 --> 00:00:54,390 And I just created a function that does absolutely nothing. 20 00:00:54,390 --> 00:00:56,043 I can just pass through. 21 00:00:57,180 --> 00:00:58,650 And these are all functions 22 00:00:58,650 --> 00:01:01,530 because the way we call them is, 23 00:01:01,530 --> 00:01:05,370 well, we say some random stuff 24 00:01:05,370 --> 00:01:07,200 and then we call it with the brackets 25 00:01:07,200 --> 00:01:09,993 and give it some sort of data or leave it empty. 26 00:01:11,730 --> 00:01:14,310 But we also learned about methods. 27 00:01:14,310 --> 00:01:17,760 And methods were different because the way we used them 28 00:01:17,760 --> 00:01:20,460 was using the dot notation. 29 00:01:20,460 --> 00:01:22,140 We said dot something. 30 00:01:22,140 --> 00:01:24,363 For example, if we had a string, hello, 31 00:01:25,650 --> 00:01:29,400 and I do dot, I get a list of all 32 00:01:29,400 --> 00:01:34,400 these methods that the string data type can use. 33 00:01:34,950 --> 00:01:39,950 These aren't things that we can use like this 34 00:01:40,260 --> 00:01:42,520 because if I do capitalize 35 00:01:45,120 --> 00:01:49,410 like this, well it's going to give me an error. 36 00:01:49,410 --> 00:01:53,250 It's going to say, well, I'm going to get an error with max 37 00:01:53,250 --> 00:01:55,500 because it's expecting an argument here. 38 00:01:55,500 --> 00:01:59,343 But let's comment this out and click run again. 39 00:02:00,240 --> 00:02:02,850 I get name capitalize is not defined 40 00:02:02,850 --> 00:02:06,450 because it's not a function, it's a method. 41 00:02:06,450 --> 00:02:10,530 And a method has to be owned by something. 42 00:02:10,530 --> 00:02:12,420 And who owns a method? 43 00:02:12,420 --> 00:02:15,300 Well, whatever's to the left of the dot. 44 00:02:15,300 --> 00:02:19,110 In our case, the string owns 45 00:02:19,110 --> 00:02:21,093 the method capitalize. 46 00:02:22,440 --> 00:02:25,080 And that's what methods are. 47 00:02:25,080 --> 00:02:29,370 They're built-in objects that have methods 48 00:02:29,370 --> 00:02:33,030 such as strings, dictionaries, sets, 49 00:02:33,030 --> 00:02:35,490 tuples, all the things we've talked about, 50 00:02:35,490 --> 00:02:37,770 where as soon as we do dot, 51 00:02:37,770 --> 00:02:40,470 we have access to all these methods. 52 00:02:40,470 --> 00:02:45,060 They're owned by an object or a data type. 53 00:02:45,060 --> 00:02:48,900 And the fun thing is that there's ways to build 54 00:02:48,900 --> 00:02:51,210 your own methods. 55 00:02:51,210 --> 00:02:53,070 And I'll show you how to do that later on 56 00:02:53,070 --> 00:02:55,410 and when we start talking about classes. 57 00:02:55,410 --> 00:02:58,830 But you can see here that our editors help us determine 58 00:02:58,830 --> 00:03:01,050 what type of methods that we can use. 59 00:03:01,050 --> 00:03:04,200 And again, these are built into Python. 60 00:03:04,200 --> 00:03:07,740 And you can also learn about these methods 61 00:03:07,740 --> 00:03:11,610 that we can use by going to the Python documentation, right? 62 00:03:11,610 --> 00:03:15,180 Python 3 documentation is going to have 63 00:03:15,180 --> 00:03:17,730 a ton of things for us. 64 00:03:17,730 --> 00:03:20,100 If we go to Library Reference, for example, 65 00:03:20,100 --> 00:03:22,710 we can see here that we can learn about built-in types. 66 00:03:22,710 --> 00:03:26,400 So let's go to, let's go to the set types. 67 00:03:26,400 --> 00:03:29,880 And here you can see that we have set type 68 00:03:29,880 --> 00:03:31,620 and it shows us how we can use it. 69 00:03:31,620 --> 00:03:35,430 Now, Python doesn't have the easiest documentation to read 70 00:03:35,430 --> 00:03:37,260 for beginners, unfortunately. 71 00:03:37,260 --> 00:03:39,960 So sometimes it's better to actually just Google 72 00:03:39,960 --> 00:03:44,460 instead of going through the actual documentation. 73 00:03:44,460 --> 00:03:48,480 But you see here that the set type has clear, 74 00:03:48,480 --> 00:03:50,940 has pop, has remove. 75 00:03:50,940 --> 00:03:53,340 If we want to use it, we have update, 76 00:03:53,340 --> 00:03:55,773 and these are the methods that we can use. 77 00:03:57,090 --> 00:03:58,620 But at the end of the day, 78 00:03:58,620 --> 00:04:02,310 both methods and functions allow us 79 00:04:02,310 --> 00:04:04,830 to take actions, right? 80 00:04:04,830 --> 00:04:06,750 To take actions on our data types, 81 00:04:06,750 --> 00:04:09,690 to have our programs do something. 82 00:04:09,690 --> 00:04:11,850 And although they have these different names, 83 00:04:11,850 --> 00:04:13,920 and one has a dot in front of it 84 00:04:13,920 --> 00:04:17,279 and another one, well, we can just call it like this. 85 00:04:17,279 --> 00:04:19,410 The difference is very minimal. 86 00:04:19,410 --> 00:04:21,660 But keep that in mind when you hear people talking 87 00:04:21,660 --> 00:04:23,400 about methods and functions. 88 00:04:23,400 --> 00:04:24,540 There is that difference. 89 00:04:24,540 --> 00:04:27,480 And like I said before, we will get to methods when we talk 90 00:04:27,480 --> 00:04:30,870 about classes to show you how we can create our own. 91 00:04:30,870 --> 00:04:32,280 I'll see you in the next one. 92 00:04:32,280 --> 00:04:33,113 Bye-bye.