Objects
Inside the class
Each class contains two kinds of information:
- Attributes;
- Methods.
An attribute is data that describes the object (like the length of the tail, the number of legs, hair color, etc.).
A method is something that an object can do. Methods can change or not change the attributes(cat can eat and its weight increases or cat can sleep, and nothing happens).
Object
An object is one of the possible representations of the class. Creating a new class object is called instantiating a new object.
Here we create a Cat
class:
12class Cat: pass
Here we create a unique cat
object based on our Cat
class:
12345678# Creating a class class Cat: pass # Instantiating an object cat = Cat() print(cat)
Дякуємо за ваш відгук!
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Запитайте мені питання про цей предмет
Сумаризуйте цей розділ
Покажіть реальні приклади
Awesome!
Completion rate improved to 7.69
Objects
Свайпніть щоб показати меню
Inside the class
Each class contains two kinds of information:
- Attributes;
- Methods.
An attribute is data that describes the object (like the length of the tail, the number of legs, hair color, etc.).
A method is something that an object can do. Methods can change or not change the attributes(cat can eat and its weight increases or cat can sleep, and nothing happens).
Object
An object is one of the possible representations of the class. Creating a new class object is called instantiating a new object.
Here we create a Cat
class:
12class Cat: pass
Here we create a unique cat
object based on our Cat
class:
12345678# Creating a class class Cat: pass # Instantiating an object cat = Cat() print(cat)
Дякуємо за ваш відгук!