0% found this document useful (0 votes)
26 views

Python 6

The document describes implementing geometry shape calculation modules in Python. It defines triangle, rectangle, and square calculation functions in separate files and imports them into a final file to call each function, outputting the semi-perimeter and area for each shape. When run, the final file outputs the calculated semi-perimeter and area for a triangle with sides 5, 6, 7, a rectangle with sides 5, 10, and a square with side 5.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Python 6

The document describes implementing geometry shape calculation modules in Python. It defines triangle, rectangle, and square calculation functions in separate files and imports them into a final file to call each function, outputting the semi-perimeter and area for each shape. When run, the final file outputs the calculated semi-perimeter and area for a triangle with sides 5, 6, 7, a rectangle with sides 5, 10, and a square with side 5.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

6.

IMPLEMENTING MODULES

//FILE 1:SAVE AS module1.py


def triangle(a,b,c):
peri = (a+b+c)/2
print (" The Semi perimeter of Triangle :", peri)
area = ( peri * (peri-a) * (peri-b) * (peri-c)) ** 0.5
print ( " The Area of Triangle is :", area)

//FILE2:SAVE AS module2.py
def rectangle(a,b):
peri = 2 * (a+b)
print (" The Semi perimeter of Rectangle :", peri)
area = a * b
print ( " The Area of Rectangle is :", area)

//FILE3:SAVE AS module3.py
def square(a):
peri = 4 * (a)
print (" The Semi perimeter of Square :", peri)
area = a * a
print ( " The Area of Square is :", area)

//FILE4:SAVE AS final.py
from module1 import triangle
from module2 import rectangle
from module3 import square
triangle(5,6,7)
rectangle(5,10)
square(5)

OUTPUT:
The Semi perimeter of Triangle : 9.0
The Area of Triangle is : 14.696938456699069
The Semi perimeter of Rectangle : 30
The Area of Rectangle is : 50
The Semi perimeter of Square : 20
The Area of Square is : 25

You might also like