Python is a multi-paradigm programming language mean it support different programming approach but one of the popular approach is creating object known as OOPs concept. OOP in Python focuses on creating reusable code for example
class Parrot:
# class attribute
species = "bird"
# instance attribute
def __init__(self, name, age):
self.name = name
self.age = age
# instantiate the Parrot class
blu = Parrot("Blu", 10)
woo = Parrot("Woo", 15)
# access the class attributes
print("Blu is a {}".format(blu.__class__.species))
print("Woo is also a {}".format(woo.__class__.species))
# access the instance attributes
print("{} is {} years old".format( blu.name, blu.age))
print("{} is {} years old".format( woo.name, woo.age))
output:
Blu is a bird
Woo is also a bird
Blu is 10 years old
Woo is 15 years old