A.A Programming Assignment Unit 4
A.A Programming Assignment Unit 4
- Define a function called `hypotenuse` that takes two arguments, `a` and `b`, representing the lengths of
the two legs of the right triangle.
```python
return 0
```
- Calculate the length of the hypotenuse using the Pythagorean theorem: \( c = \sqrt{a^2 + b^2} \).
```python
import math
return math.sqrt(a ** 2 + b ** 2)
```
```python
import math
def hypotenuse(a, b):
return math.sqrt(a ** 2 + b ** 2)
```
```python
import math
return math.sqrt(a ** 2 + b ** 2)
```
In this incremental development process, we started with a basic function definition and gradually added
functionality while testing each stage to ensure correctness. Finally, we tested the function with different
arguments to confirm its effectiveness.
```python
“””
This function performs some useful computation using the given arguments.
“””
Return 0
```
```python
“””
This function performs some useful computation using the given arguments.
“””
Return result
# Testing the function
```
- Expand the functionality of the function to handle more complex computations or additional
arguments.
```python
“””
This function performs some useful computation using the given arguments.
“””
Return result
```
In this development process, I started by defining the problem and creating a basic function skeleton.
Then, I incrementally added functionality to the function while testing it with various inputs to ensure
correctness and robustness. Finally, I tested the function with different arguments to showcase its
versatility and usefulness. This incremental approach highlights my problem-solving skills and
programming proficiency, making it a valuable addition to my portfolio.
Reference
Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts:
Green Tree Press. https://greenteapress.com/thinkpython2/thinkpython2.pdf