68.7k views
2 votes
In this assignment, you will write a Python 3.x program to calculate the length of the hypotenuse (side C) of a right triangle, given the lengths of the other two sides (A & B) as provided by the user. The program will also calculate the area of the triangle and the perimeter (the sum of the three sides). Other specifications: WRITE THE CODE FOR THE ANSWER.

User Gerg
by
7.1k points

1 Answer

3 votes

Answer:

Step-by-step explanation:

from math import hypot #import hypot for finding the hypotenuse

a = int(input("Enter a value for a: " )

b = int(input("Enter a value for b: " )

def find_hypotenuse(a,b):

return hypot(a,b) #find the hypotenuse

def find_area(a,b):

return 0.5 * a * b #calculate the area

def find_perimeter(a,b):

return a + b + find_hypotenuse(a,b) #calculate the perimeter

print("the hypotenuse is :", find_hypotenuse(a,b))

print("the area is :", find_area(a,b))

print("the perimeter is :", find_perimeter(a,b))

User Tkarls
by
6.6k points