[MUSIC]
Hi Pythonistas.
My name is Megan and I'm a teacher here at Treehouse.
My pronouns are she, her, hers.
In this course,
I'll teach you about the wonderful world of object-oriented programming.
I'm gonna start with a little advice.
Object-oriented programming or OOP, can be confusing to learn,
since it involves a different way of thinking about your code.
It usually takes a bit before the knowledge sinks in and
this new way of thinking clicks.
My advice is to plan on rewatching videos,
trying out some code on your own and asking lots of questions.
Ready to jump in?
Let's go.
[SOUND] Object-oriented-programming is the way to structure
your code into groups of properties and behaviors.
These groups are objects.
Structuring your code in this way is similar to a lot of real world objects.
Let's see as an example of a car.
[SOUND] A car is an object that has properties like
four wheels, at least two doors.
It has a make, model and year it was made.
It has behaviors like stop, go, and turning.
All of these things make up our object car.
Properties are things the object has, like a dog has a tail and two ears.
While behaviors are usually things the object does, like bark or chase the ball.
I wanna challenge you to think of an object on your own and
list a few properties and behaviors.
Pause this video, write or type your idea, and then unpause when you're ready.
Go ahead and pause me.
What did you come up with?
The example I went with is a TV.
Its properties are screen size, power buttons and HDMI ports.
Its behaviors are turning off or on, increasing or
decreasing the volume and muting the sound.
You may be wondering why it is important to learn this way of structuring code.
Well, OOP is a popular way to organize code and
is how most of the libraries you have or will work with are structured.
Knowing OOP will make understanding how those libraries work a lot easier.
Think about strings.
Strings are an object in Python.
One property they have is they are immutable,
which means they cannot be changed.
Here I have a variable called my name that holds a string.
If I try to change a letter to something else,
I get an error.
You have probably used a few of their behaviors already like lower,
which turns the string into all lowercase letters.
Upper which turns the string into all uppercase letters and format.
Which lets you pass in some arguments to place inside of your string.
Dictionaries, lists, sets and tuples are all Python objects too.
Take a second to think about what their properties and behaviors are.
Pause me and write or type your ideas.
Go ahead.
Back?
In the teachers notes below, you can find a link
to the Python documentation to find details on the string object.
If you haven't looked at the Python documentation yet,
I highly recommend you take some time to do so now.
Knowing how to navigate documentation
will become more important as you level up in your programming skills.
To help solidify this new idea of object-oriented programming,
try to think about things you've interacted with today,
in terms of their properties and behaviors.
Nice work Pythonistas.