In: Computer Science
Please submit a screenshot of where your code got compiled, executed, showing the execution result
Write a program/function in python that will perform the following functions, when the program is executed, to demonstrate the features of an OOP language—ADT, inheritance, and polymorphism:
Please DO NOT hard-code any input values, output values in your code.
Below is the answer:
def AreaCircle():
  Radius=0
  while(Radiius<=0):
    Radius = float(input('Enter the Circle Radius (>0) = '))
  A = 3.1457 * Radius * Radius
  return A
   
   
def AreaRectangle():
  Flag=1
  while(Flag):
    Flag=0
    Dim = (input('Enter the Length and Width = '))
    x = (Dim.split(' '))
    if(len(x)==2):
      if(float(x[0])==0 or float(x[1])==0): Flag=1
    else:
      Flag=1
  A = float(x[0])*float(x[1])
  return A
def AreaSquare():
  Side=0
  while(Side<=0):
    Side = float(input('Enter the Square Side (>0) = '))
  A = Side * Side
  return A
def AreaParallelogram():
  Flag=1
  while(Flag):
    Flag=0
    Dim = (input('Enter the Base and Height (>0) = '))
    x = (Dim.split(' '))
    if(len(x)==2):
      if(float(x[0])==0 or float(x[1])==0): Flag=1
    else: Flag=0   
  x = (Dim.split(' '))
  A = float(x[0])*float(x[1])
  return(A)
def IsValid(Side1,Side2,Side3):
  Flag=0;
  Sum = Side1 + Side2
  if(Sum>Side3 and Flag==0):
     Flag=1    
  Sum = Side2 + Side3
  if(Sum>Side1 and Flag==0):
     Flag=1    
  Sum = Side1 + Side3
  if(Sum>Side2 and Flag==0):
     Flag=1    
  return Flag
def Area(Side1,Side2,Side3):
   u = float(Side1)
   v = float(Side2)
   w = float(Side3)
    
   s = (u+v+w)/2
   A = math.sqrt(s*(s-u)*(s-v)*(s-w))
   return(A)
    
Command=6
Flag=1
while(Flag):
  Command=6
  while(Command<0 or Command>5):
    print("\nFor Triangle,  Press --> 1")
    print("For Rectangle,   Press --> 2")
    print("For Square,    Press --> 3")
    print("For Circle,    Press --> 4")
    print("For Parallelogram, Press --> 5")
    print("To QUIT,      Press --> 0")
    Command= int(input('Enter the Shape No. (1 to 5): '))
  Ar=0;
  if(Command == 0):
    Flag=0
  if(Command == 2):
    Ar = AreaRectangle();
    print("Area of Rectangle = %s"%Ar)
  if(Command == 3):
     Ar = AreaSquare();
     print("Area of Square = %s"%Ar)
  if(Command == 4):
     Ar = AreaCircle();
     print("Area of Circle = %s"%Ar)
  if(Command == 1):
    x=[]
    while(len(x)!=3):
      Sides= input('Enter three sides of a triangle followed by space: ')
      x = Sides.split()
    a = int(x[0])
    b = int(x[1])
    c = int(x[2])
    TriangleValidFlag = IsValid(a,b,c)
    if(TriangleValidFlag):
       print("TRUE: The sides are valid.")
       Ar = Area(a,b,c)
       print("Area = %s"%Ar)
    if(TriangleValidFlag==0):
       print("FALSE: The sides are not valid")
  if(Command == 5):
    Ar = AreaParallelogram();
    print("Area of parallelogram = %s"%Ar)