# Class Instance

**Channel:** MIT OpenCourseWare
**Source:** https://www.youtube.com/watch?v=2__KumJsGXc
**Transcript page:** https://www.withtranscript.ai/video/2__KumJsGXc

## Chapters

- 0:00 — Chapter 1 (0:00)

## Transcript

**[0:00]:** The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To make a donation or view additional materials from hundreds of MIT courses, visit MIT OpenCourseWare at ocw.mit.edu.

**[0:23]:** We have this definition for the class object. I've cre- um I've created the init for you. And here I'm giving it self, which is the first thing that you have to give it, and then two parameters, W and D. And for for an instance of a car, I'm going to assign the data attribute named wheels to whatever is passed in for W. So, notice that they're not the same name. And the data attribute for doors is going to be the value that's passed in for D. Okay? And also notice that inside the init, I can do any other sort of initializations that I'd like. So, it's not just assigning variables from the parameters to local to um to variables for for my objects. So, in this case, I'm I'm creating a new data attribute named color, and I'm going to just create it to be an empty string.

**[1:18]:** Okay? Notice because I didn't even even though I didn't pass in any color to my uh to my object. So, the question says, "Using the class definition above, which line creates a new car object with four wheels and two doors?" Okay? So, this um this first one is not right because it's trying to call the class with a variable, my car, so for self, which isn't quite right. So, when you're creating a when you're creating your object, you have to give it one less parameter than what you have. So, here we're just going to have to create it with the W and the D. So, we're going to create this the these variable this variable my car. And we're going to assign it four for the number of uh wheels and two for the number of doors. And the number of wheels is the first parameter and the number of doors is the second one.

**[2:13]:** So, it should be this one here. car 4,2 So, that's this one. Perfect.
