WEBVTT

00:00.000 --> 00:05.000
Basics of Classes and Objects

00:05.000 --> 00:07.000
In this video, we will learn

00:07.000 --> 00:10.000
No Classes and Objects

00:10.000 --> 00:13.000
Define Attributes and Methods

00:13.000 --> 00:18.000
Create and Use Objects

00:18.000 --> 00:20.000
Understanding Classes

00:20.000 --> 00:25.000
A class is like a blueprint or template for making something. It tells Python

00:25.000 --> 00:28.000
What information the object will have, attributes

00:28.000 --> 00:32.000
What actions the object can do, methods, example

00:32.000 --> 00:34.000
A car blueprint might say

00:34.000 --> 00:38.000
Information, brand, model, color

00:38.000 --> 00:42.000
Actions, start, stop, honk

00:42.000 --> 00:45.000
What is an object?

00:45.000 --> 00:50.000
An object is something we build from a class. It's the real thing made from the blueprint

00:50.000 --> 00:53.000
If the class is car, then

00:53.000 --> 01:00.000
Car 1, car 2, car 3, and car 4 are 4 different objects created from that blueprint

01:00.000 --> 01:04.000
They can have the same or different values for color and doors

01:04.000 --> 01:06.000
Quick Thinking Task

01:06.000 --> 01:14.000
Before we write any code, think of any object in real life, like a ball, bag, or chair

01:14.000 --> 01:17.000
Write down two things about it, attributes

01:17.000 --> 01:22.000
One thing it can do, action, example, ball, attributes, color, size

01:22.000 --> 01:25.000
Action, bounce

01:25.000 --> 01:29.000
Let's understand it with the help of code

01:29.000 --> 01:31.000
Here the class car

01:31.000 --> 01:34.000
We are creating a class called car

01:34.000 --> 01:37.000
This is like making a blueprint for cars

01:37.000 --> 01:42.000
Def underscore in it underscore bracket self, color, doors

01:42.000 --> 01:45.000
This is the constructor method

01:45.000 --> 01:48.000
It runs automatically when we create a new car object

01:48.000 --> 01:51.000
Color and doors are parameters

01:51.000 --> 01:54.000
The information we give when we make a new car

01:54.000 --> 01:58.000
Self dot color and self dot doors are attributes

01:58.000 --> 02:00.000
They store the object's data

02:00.000 --> 02:04.000
Def display underscore info bracket self

02:04.000 --> 02:07.000
This is a method, a function inside the class

02:07.000 --> 02:13.000
It uses self dot color and self dot doors to print details about the car

02:13.000 --> 02:18.000
Car 1 equals car bracket, red, car 4

02:18.000 --> 02:22.000
We create an object called car 1 from the car class

02:22.000 --> 02:25.000
Red goes into color and 4 goes into doors

02:25.000 --> 02:30.000
Car 2 equals car bracket, blue, comma 2

02:30.000 --> 02:35.000
Another object from the same class, but with different data

02:35.000 --> 02:44.000
Car 1 dot display underscore info, empty parentheses and car 2 dot display underscore info

02:44.000 --> 02:50.000
Empty parentheses, we call the display underscore info method for each object

02:50.000 --> 02:54.000
Each object uses its own data to show the result

02:54.000 --> 02:58.000
Let's check the output

02:58.000 --> 03:03.000
Now you know how to create classes, make objects and use their attributes and methods

03:03.000 --> 03:08.000
Practice by designing your own class and bringing it to life with objects

