Computer Science

Write a function called calculate_area() that takes base and height as input arguments and returns area of a triangle as an output. The formula used is: Triangle Area = 1⁄2 * base * height

Python

Python Functions

7 Likes

Answer

def calculate_area(base, height):
    area = (1/2) * base * height
    return area

base_value = int(input("Enter the base value: "))
height_value = int(input("Enter the height value: "))
triangle_area = calculate_area(base_value, height_value)
print("Area of the triangle:", triangle_area)

Output

Enter the base value: 10
Enter the height value: 5
Area of the triangle: 25.0

Answered By

3 Likes


Related Questions