
Python For Beginners
May 24, 2025 at 04:06 PM
🚀 Think You Know Python OOP? Test Your Skills! 🚀
What does this code output? 🤔💻
class Shape:
def area(self):
return 0
class Square(Shape):
def __init__(self, side):
self.side = side
def area(self):
return self.side * self.side
shape = Shape()
square = Square(4)
print(shape.area())
print(square.area())
🔮 Pick the right answer:
🟢 A) 0 \n 16
🔵 B) 0 \n 0
🟠 C) Error
🔴 D) 16 \n 16
💬 Comment your answer below! Let’s see who gets it right.
📚 Learn More:
📌 Python Polymorphism Explained – Types & Examples (OOP Guide)
https://yasirbhutta.github.io/python/docs/oop-polymorphism/
📢 Want daily coding challenges? Join our WhatsApp group!
👉 https://bit.ly/4jbf36m
#learnwithyasir #yasirbhutta