Explain the concept of object-oriented programming (OOP) and how it is implemented in Python.
Object-oriented programming is a programming paradigm that structures code around objects, which represent real-world entities. It promotes modularity and reusability. In Python, everything is an object. Classes define blueprints for creating objects, and objects are instances of classes. Classes encapsulate data (attributes) and behavior (methods). Here's a simple example:
class Dog: def __init__(self, name): self.name = name def bark(self): return "Woof!" # Creating an instance of the Dog class my_dog = Dog("Buddy") print(my_dog.name) print(my_dog.bark())