Unit4 Computer Assignment
Unit4 Computer Assignment
Stage 1:
Python
def hypotenuse(a, b):
"""Calculates the length of the hypotenuse of a right triangle given
the lengths of the other two legs as arguments.
Args:
a: The length of one leg of the right triangle.
b: The length of the other leg of the right triangle.
Returns:
The length of the hypotenuse of the right triangle.
"""
Output:
5.0
13.0
23.0
Stage 2:
Args:
a: The length of one leg of the right triangle.
b: The length of the other leg of the right triangle.
Returns:
The length of the hypotenuse of the right triangle.
"""
return c
Output:
5.0
13.0
23.0
Conclusion:
Problem:
Solution:
Python
def sum_of_squares(list1):
"""Calculates the sum of the squares of all the numbers in a given
list.
Args:
list1: A list of numbers.
Returns:
The sum of the squares of all the numbers in the list.
"""
sum_of_squares = 0
return sum_of_squares
print(sum_of_squares(list1))
print(sum_of_squares(list2))
Output:
55
105
Explanation: