Instructor: Hey, long time, no see.
It's, it's been a while but I'm glad you're back
and I'm glad you're still hanging in there.
Trust me, things, things are going to get a lot more fun
once we actually start building applications
but we do have to go through the basics, so hang in there.
Now, you may have heard me mention
methods and functions before.
And I briefly touched on the subject, right?
We have functions like list, print.
We have things like max, min, what else do we have?
We have input,
these are all built-in functions in Python.
Python just comes with this and we're able to use them.
And we also learned about functions
that we can create ourselves.
Custom functions like, well,
some random stuff.
And I just created a function that does absolutely nothing.
I can just pass through.
And these are all functions
because the way we call them is,
well, we say some random stuff
and then we call it with the brackets
and give it some sort of data or leave it empty.
But we also learned about methods.
And methods were different because the way we used them
was using the dot notation.
We said dot something.
For example, if we had a string, hello,
and I do dot, I get a list of all
these methods that the string data type can use.
These aren't things that we can use like this
because if I do capitalize
like this, well it's going to give me an error.
It's going to say, well, I'm going to get an error with max
because it's expecting an argument here.
But let's comment this out and click run again.
I get name capitalize is not defined
because it's not a function, it's a method.
And a method has to be owned by something.
And who owns a method?
Well, whatever's to the left of the dot.
In our case, the string owns
the method capitalize.
And that's what methods are.
They're built-in objects that have methods
such as strings, dictionaries, sets,
tuples, all the things we've talked about,
where as soon as we do dot,
we have access to all these methods.
They're owned by an object or a data type.
And the fun thing is that there's ways to build
your own methods.
And I'll show you how to do that later on
and when we start talking about classes.
But you can see here that our editors help us determine
what type of methods that we can use.
And again, these are built into Python.
And you can also learn about these methods
that we can use by going to the Python documentation, right?
Python 3 documentation is going to have
a ton of things for us.
If we go to Library Reference, for example,
we can see here that we can learn about built-in types.
So let's go to, let's go to the set types.
And here you can see that we have set type
and it shows us how we can use it.
Now, Python doesn't have the easiest documentation to read
for beginners, unfortunately.
So sometimes it's better to actually just Google
instead of going through the actual documentation.
But you see here that the set type has clear,
has pop, has remove.
If we want to use it, we have update,
and these are the methods that we can use.
But at the end of the day,
both methods and functions allow us
to take actions, right?
To take actions on our data types,
to have our programs do something.
And although they have these different names,
and one has a dot in front of it
and another one, well, we can just call it like this.
The difference is very minimal.
But keep that in mind when you hear people talking
about methods and functions.
There is that difference.
And like I said before, we will get to methods when we talk
about classes to show you how we can create our own.
I'll see you in the next one.
Bye-bye.