Abstract Class in Python
Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python
Program 1
# Abstract class and methods
from abc import ABC,abstractmethod
# class Button(ABC):
# @abstractmethod
# def click(self):
# None
# class Color(Button):
# None
# # def click(self):
# # print("Its Red Color now")
# class Image(Button):
# def click(self):
# print("Its My Photo now")
# C=Color()
# C.click()
# I=Image()
# I.click()
class Area(ABC):
@abstractmethod
def area(self):
None
class Circle(Area):
def area(self):
r=float(input("Enter Radious of Circle"))
A=3.14*r*r
print("Area= ",A)
class Rect(Area):
def area(self):
l=float(input("Enter length"))
b=float(input("Enter bridth"))
print("Area=",(l*b))
# C=Circle()
# C.area()
R=Rect()
R.area()
We work very hard to provide you quality material
Could you take 15 seconds and share your happy experience on Google

