Python Function that prints perimeter and area of right triangle.

#Python Function that prints perimeter and area of right triangle.

import math  
def triangle_area(a, b, c):
	s = (a+b+c)/2
	area = float(math.sqrt(s*(s-a)*(s-b)*(s-c)))
	return area
def triangle_perimeter(a,b, c):
	perimeter = a+b+c
	return perimeter    
print("\nPlease Enter three sides of triangle")
a = int(input())
b = int(input())
c = int(input())
peri=triangle_perimeter(a,b,c);
ar=triangle_area(a,b,c);
print("\nPerimeter of Traiangle = ", peri)
print("\nArea of triangle = ", ar)

Output :
Please Enter three sides of triangle
2
3
4

Perimeter of Traiangle = 9.00

Area of triangle = 2.90



Leave a comment