Challenge: Find the Area of a Triangle

This challenge requires you to implement a root function.

Problem Statement

  • The task is to call the root function my_area that calculates the area of a triangle.

AreaArea ofof aa triangletriangle = 1/2baseheight1/2 * base * height

  • A method triangle_area() is defined within the module shapes.
  • The task is to complete the method
    • Implement root function.
    • Call the root function my_area from within the public function triangle_area().
    • Print the return value from the root function, i.e., area of the triangle

Input

   x and y

Note: Assume that base and height are passed to the function my_public_function

Output

The area of a triangle

   float value

Sample Input

   x = 3, y = 4

Sample Output

   6

Coding Exercise

Write your code below. It is recommended​ that you try solving the exercise yourself before viewing the solution.

Note: There is a my_public_function function in module my_module given in the code for testing purposes. Do not modify it.

Good luck!🤞

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy