AIM: WAP for the task mentioned in the below ‘task to be done’ section
Student Name: Arman Thakur UID: 20BCS6147
Branch: BE-CSE Big Data Section/Group: 20BDA4-B
Semester: 4th Subject Code: 20CSP-286
Subject Name: Programming in Python Lab
1. Tasks to be done:
Create an abstract class Shape having an abstract method area (self, x, y). Create
two subclasses Rectangle and Circle that will override the area () method of Shape
class. Finally create objects of Rectangle and Circle class and find the area.
2. Code:
from abc import ABC, abstractclassmethod, abstractmethod
abstractclassmethod
class Shape(ABC):
pass
@abstractmethod
def area(self):
pass
class circle(Shape):
def __init__(self,radius):
self.__radius=radius
Department of Computer Science and Engineering, AIT
def area(self):
return 3.14*self.__radius*self.__radius
class Rectangle(Shape):
def __init__(self,length,breath):
self.__length=length
self.__breath=breath
def area(self):
return self.__length*self.__breath
C1=circle(4)
print(C1.area())
R1=Rectangle(2,4)
print(R1.area())
3. Screenshots:
Department of Computer Science and Engineering, AIT
4. Result/Output:
Learning outcomes (What I have learnt):
1. Python Programming.
2. Print output
3. Abstract classes
4. Making Subclasses
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
Sr. No. Parameters Marks Obtained Maximum Marks
1.
2.
3.
Department of Computer Science and Engineering, AIT
Department of Computer Science and Engineering, AIT