Attributes and Methods
Understand how attributes and methods define the behavior of objects.
1
Introduction to Attributes and Methods
Attributes and methods define the characteristics and behavior of objects in Object-Oriented Programming (OOP). Attributes store data, while methods perform actions.
In this lesson, you’ll learn how to define and use attributes and methods effectively in Python classes.

2
What Are Attributes?
Attributes are variables that belong to a class or an object. They are defined inside the class and describe the properties of an object:
# Defining attributes in a class
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
person1 = Person("Alice", 30)
print(person1.name, person1.age)