Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Functions Objectives: calling an existing function writing a function based on a

ID: 3692904 • Letter: F

Question

Functions Objectives: calling an existing function writing a function based on a specification testing your own function Part 1 t is an important skill to test functions to ensure they work correctly. In part 1, you're given a function definition that you need to test. Download this starter code. (right-click on the link and then choose: Save Link As) . Read over the function definition. Next, edit the program so that main() calls the function two times and displays results to the user. Here are the test cases base base2 height area - expected result 36 40.5 4 7 Part 2: The next skill to practice is writing your own function definition and then testing the function. In the same file, write a new function definition that is passed in the 2 legs of a right triangle, a and b, and then calculates and returns the hypoteneuse. Do not use the math.hypot () function. Your task is to implement the math yourself. Come up with 2 tests cases with the expected results calculated by hand. Test your function (call it and display the results) to confirm that the actual results of your function match the expected results Write a function block comment for your function definition that follows the same style as the comment for the areaTrapezoid() function. . NOTE: Your program should only have 1 main() function definition and only 1 call to main() at the bottom of the file. Put all the calls to areaTrapezoid() and your hypotenuse function inside main() Submit your file when you're done. Make sure to add your name to the file.

Explanation / Answer

Given below are the code with comments to expalin the working of code:

part 1 and part 2:

import math

def main():

    //function calling fpr part 1://   

a = areaTrapezoid(4, 5, 8)

        b = areaTrapezoid(2, 7, 9)

//for trapezoid//

def areaTrapezoid(base1, base2, height):

        area = height / 2.0 * (base1 + base2)

        return area

//part 2-hypoteneous//

def hypo(a, b):

        hypot = (a ** 2, b ** 2) ** .5

        return hypot

main()