From the course: Intermediate Python for Non-Programmers
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Methods - Python Tutorial
From the course: Intermediate Python for Non-Programmers
Methods
- [Instructor] Now I know we went hard in the last video learning about instances. We're going to tackle a new concept in this video that's going to be a little bit easier and will actually help reinforce what we learned with instances. We're going to be learning about methods. So, simply put a method is a function that's inside of a class. It really doesn't need to be more complex than that. So let's go ahead and clear this little menu to the side here so we have more space to see our code and let's go ahead and create our very first method. So again, a method is just a function inside of a class. So if we have this dog and the dog has a name and a lucky number, what else should a dog be able to do? Maybe it should be able to bark. And in this case, our version of barking is just printing something. So let's go ahead and create a function and make sure that you're tabbed over to signify that this is inside of the class. So we have def and we're going to give it a name. In this case…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.