DevOps Classroom notes 15/Oct/2025

Object Oriented Programming Continued

  • Composition refers to has-a relationship
class Engine:
    def __init__(self, manufacturer: str):
        self.manufacturer = manufacturer

    def start(self):
        print("Engine Started")

    def stop(self):
        print("Engine Stopped")

class Car:
    def __init__(self, engine:Engine):
        self.engine: Engine = engine

    def start(self):
        print("Battery started")
        self.engine.start()
        print("AC on...")


engine = Engine("Fiat")
car = Car(engine)
car.start()
  • Refer Here for objects
  • python does not support private or protected as keywords but by conventions we can acheive the same behavior. when every we add __ double underscore as prefix member or method it cannot be accessed from outside
  • Abstract classes in python
  • Refer Here for notebook

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube