From the course: Introduction to Career Skills in Software Development
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Creating and using a class - Python Tutorial
From the course: Introduction to Career Skills in Software Development
Creating and using a class
- [Instructor] Object-oriented programming represents real-world things and situations with classes. A class is a blueprint for how other objects should be created. Python supports the creation of classes with the class keyword. Let's create a class together to see how it's done. We'll start by using the class keyword. And then we're going to put the name of our class. In this case, it's going to be Puppy. This will be followed by open and close parentheses, and then the colon. On the next line, we're going to create a special function called init. Init's job is to assign values to any variables that we need for our class to work. Don't worry about the specifics of the syntax. I'd just like you to follow along so you can have a high-level understanding of how classes work in Python. So we'll start by using the def keyword. And then we're going to do two underscores and init, another two underscores, and then a set of…
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.