Program to Implement Interface in Python || Python
In this we are going to see a basic program to implement interface in Python Programming Language.



# Person is an interface with only info as abstract method
from abc import ABC, abstractmethod


class Person(ABC):
    @abstractmethod
    def info(self):
        pass


class Student(Person):
    def info(self):
        print("This is a student class")


class Teacher(Person):
    def info(self):
        print("This is a Teacher class")


obj1 = Student()
obj1.info()

obj2 = Teacher()
obj2.info()

# Coded by Shreya Idate


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post