UNIT 4 PROGRAMMING ASSIGNMENT
UNIT 4 PROGRAMMING ASSIGNMENT
Group: 0036.
You work as a software developer in a company that creates custom software solutions for
various clients. Your company has been approached by an educational client who wants to
develop a function that calculates the length of the hypotenuse of a right triangle given the
lengths of the other two legs as arguments. Your manager has instructed you to use incremental
development to create the necessary function and document each stage of the development
process. After completing the final stage of development, you have to test the function with
Tasks
o An explanation of each stage of development, including code and any test input
and output.
I reviewed the problem and identified the use of the Pythagorean Theorem to calculate the
hypotenuse. The function needs to calculate the hypotenuse (ccc) of a right triangle using the
Pythagorean theorem:
I Written the basic function using Python, ensuring it uses mathematical operations to compute
Output
for the square root calculation. Validated the function with three test cases: (3, 4), (6, 8), and (5,
Test the function with additional inputs to ensure it works for various cases.
Test Case 2:
Output
Test Case 3:
Output
Part 2
You are a software developer who wants to establish yourself as a skilled and versatile
programmer. To achieve this, you have decided to create a work portfolio that showcases your
ability to develop custom software solutions. This portfolio will be your gateway to attract
As part of your portfolio, you plan to create your own function that does some useful
programming skills and problem-solving abilities. You will document each stage of the
development process, including the code and any test input and output in your Programming
Assignment.
Developing a Custom Function for Portfolio
function called find_primes_in_range. This function computes all prime numbers within a
clarity and optimization. Below, I explain each stage of the development process.
The task is to find all prime numbers within a given range. A prime number is a number greater
than 1 that has no divisors other than 1 and itself. The function will:
1. Take two integers as input: the start and end of the range.
The initial step is creating a function that identifies whether a single number is prime.
Explanation: The is_prime function checks divisors up to the square root of the number for
Explanation: The function iterates over the range, checking each number with is_prime. Valid
Test Case 1: The primes between 10 and 20 are [11, 13, 17, 19].
Test Case 2: The primes between 1 and 10 are [2, 3, 5, 7]. The function ensures the range
Test Case 3: An invalid range produces the error message "Invalid range: start must be
Conclusion
This project demonstrates problem-solving, input validation, optimization, and clarity in code. It
showcases the ability to handle edge cases and write reusable functions. By documenting each
stage of the development process, potential clients gain insight into the approach and attention to
detail.