Question

Write a function, named hypotenuse, that takes two arguments corresponding to the lengths of the sides...

Write a function, named hypotenuse, that takes two arguments corresponding to the lengths of the sides adjacent to the right angle of a right-triangle and that returns the hypotenuse of the triangle. You will need to use the math.sqrt function from the math library, so be sure to import math at the top of your source file.

Homework Answers

Answer #1
import math
def hypotenuse(a,b):
    return math.sqrt(math.pow(a,2)+math.pow(b,2))

if __name__ == "__main__":
    print("Hypotenuse Example")
    a = int(input("Enter Side One:\n"))
    b = int(input("Enter Side Tw:\n"))
    print("Hypotenuse is %0.4f"%(hypotenuse(a,b)))



Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Python As an exercise, use incremental development to write a function called hypotenuse that returns the...
Python As an exercise, use incremental development to write a function called hypotenuse that returns the length of the hypotenuse of a right triangle given the lengths of the other two legs as arguments. Record each stage of the development process as you go. After the final stage of development, print the output of hypotenuse(3, 4) and two other calls to hypotenuse with different arguments. Include all of the following: An explanation of each stage of development, including code and...
Write Python expressions corresponding to the following statements: The length of the hypotenuse in a right...
Write Python expressions corresponding to the following statements: The length of the hypotenuse in a right triangle whose other two sides have lengths a and b The value of the expression that evaluates whether the length of the above hypotenuse is 5 The area of a disk of radius a The value of the Boolean expression that checks whether a point with coordinates x and y is inside a circle with center (a, b) and radius r
(Sides of a Right Triangle) Write a function that reads three nonzero integers and determines whether...
(Sides of a Right Triangle) Write a function that reads three nonzero integers and determines whether they are the sides of a right-angled triangle. The function should take three integer arguments and return 1 (true) if the arguments comprise a right-angled triangle, and 0 (false) otherwise. Use this function in a program that inputs a series of sets of integers. Hint: a^2+b^2=C^2 in c programming
Q.1. Write a program that accepts the lengths of three sides of a triangle as inputs....
Q.1. Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is an equilateral triangle. Q.2. Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is a right triangle. Recall from the Pythagorean theorem that in a right triangle, the square of one side equals the sum of the...
Must satisfy the following: Define a function named series. This function will accept two arguments, both...
Must satisfy the following: Define a function named series. This function will accept two arguments, both integers, named base and span. The function will compute the sum of the integers, starting at the value of base and down to 0 (zero) that are span apart. In other words, if base is 19 and span is 3, series will compute the sum of 19 + 16 + 13 + 10 + 7 + 4 + 1. The series function does not...
Write a function in (C++) named - accending_order - that takes a reference to a vector...
Write a function in (C++) named - accending_order - that takes a reference to a vector of string (like {"HI 32", "HELLO 78", "NAME 97", "WORLD 07"}), and returns nothing. The function should reorder the vector so that the courses are sorted by number in ascending order. Write this function without - int (main). CODE IN C++ ONLY. EXPECTED OUTPUT: {"WORLD 07", "HI 32", "HELLO 78", "NAME 97"}
Use python write a function that takes the scores of all players as keyword arguments and...
Use python write a function that takes the scores of all players as keyword arguments and returns the name of the player with maximum score after calculating the scores with the truncated mean scoring(remove one highest score and one lowest score). Do not import anything eg. def bp(**player_scores):     >>> bp(ab=[9.6, 9, 9.8, 9.9], bc=[9.0, 9.5, 9.9],cd=[10.0, 9.8, 10.0, 9.5, 9.6])     'cd'     >>> bp(ab=[3.8, 3.5, 3.2], bc=[4.0, 3.6, 3.0])     'bc'   
8) Write Python code for a function called occurances that takes two arguments str1 and str2,...
8) Write Python code for a function called occurances that takes two arguments str1 and str2, assumed to be strings, and returns a dictionary where the keys are the characters in str2. For each character key, the value associated with that key must be either the string ‘‘none’’, ‘‘once’’, or ‘‘more than once’’, depending on how many times that character occurs in str1. In other words, the function roughly keeps track of how many times each character in str1 occurs...
Use python (matplotlib) Write a function plot_profit(c, i, n) that takes three arguments: c is the...
Use python (matplotlib) Write a function plot_profit(c, i, n) that takes three arguments: c is the starting capital, i is the yearly interest rate, and n is the number of years. The function should plot the projected capital over the next n years assuming that each year the capital is multiplied by 1 + i/100%. The plot should be saved in a file called 'profit_projections.pdf'.
1. Write a function called compute_discount which takes a float as the cost and a Boolean...
1. Write a function called compute_discount which takes a float as the cost and a Boolean value to indicate membership. If the customer is a member, give him/her a 10% discount. If the customer is not a member, she/he will not receive a discount. Give all customers a 5% discount, since it is Cyber Tuesday. Return the discounted cost. Do not prompt the user for input or print within the compute_discount function. Call the function from within main() and pass...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT