0% found this document useful (0 votes)
19 views1 page

4

The document defines two classes - rectangle and square - that calculate and print the area. It takes length, breadth and side dimensions as input and creates objects to call the display and area methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

4

The document defines two classes - rectangle and square - that calculate and print the area. It takes length, breadth and side dimensions as input and creates objects to call the display and area methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#!

/bin/python3

import math
import os
import random
import re
import sys

# Write your code here


# Create the rectangle class and print a message plus the area
class rectangle(object):
def display(self):
print('This is a Rectangle')
def area(self, Lenght, Breadth):
area = Lenght * Breadth
print(f'Area of Rectangle is {area}')

# Create the square class and print a message plus the area
class square(object):
def display(self):
print('This is a Square')
def area(self, Side):
area = Side * Side
print(f'Area of square is {area}')

# Function used to input the data


if __name__ == '__main__':

l = int(input())
b = int(input())
s = int(input())

obj1 = rectangle()
obj1.display()
obj1.area(l,b)

obj2 = square()
obj2.display()
obj2.area(s)

# STDIN
# 5
# 4
# 6

# This is a Rectangle
# Area of Rectangle is 20 (Double Spaces)
# This is a Square
# Area of square is 36 (Double Spaces)

You might also like