Write a Python program to find the area and perimeter of a right-angled triangle and print the perimeter and area.


Topic: Write a Python program to find the area and perimeter of a right-angled triangle and print the perimeter and area.

Solution

import math 
AB = input("Length of the first leg: ") 
AC = input("Length of the second leg: ") 
AB = float(AB) 
AC = float(AC) 
BC = math.sqrt(AB  2 + AC  2) S = (AB * AC) / 2
P = AB + AC + BC 
print("Area of the triangle: %.2f" % S)
print("Perimeter of the triangle: %.2f" % P) 



List all Python Programs