Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Objects | Classes and Objects
Object-Oriented Programming in Python

bookObjects

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:

12
class Cat: pass
copy

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)
copy

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 2

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Ask me questions about this topic

Summarize this chapter

Show real-world examples

Awesome!

Completion rate improved to 7.69

bookObjects

Swipe to show menu

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:

12
class Cat: pass
copy

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)
copy

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 2
some-alt