Programming Assignment Unit 4
Programming Assignment Unit 4
Ayesha Gul
Dr Josiah Jolaoluwa
This assignment will assess your skills and knowledge in developing a function through an
incremental development process such that the debugging becomes fast. There are two parts of
Part 1:
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
1. An explanation of each stage of development, including code and any test input
and output.
Answer:
The problem requires calculating the hypotenuse of a right triangle given the two other sides
c = √a2+b2
where c is the hypotenuse, and a and b are the two given sides.
We first create a function hypotenuse(a, b) that takes two arguments and returns their squared
sum:
Output:
4
Programming Assignment Unit 4
(We are getting a² + b², but we still need to apply the square root.)
To get the correct hypotenuse value, we now take the square root of a² + b²:
Output:
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.
6
Programming Assignment Unit 4
Answer:
given password and categorizes it as Weak, Medium, or Strong based on length and complexity.
We start by defining a function that accepts a password as input and returns its length.
Output:
7
Programming Assignment Unit 4
Output:
8
Programming Assignment Unit 4
2. Lowercase letters
3. Numbers
Output:
Explanation of Fix:
The Strong category should only apply to passwords longer than 10 characters that also
In the previous version, Strong@123 was not recognized as Strong because the check for
Reordering the conditions ensures that "Strong" passwords are detected correctly.
The password strength checker function is a useful tool that helps evaluate how secure a
password is based on length and complexity. By checking for uppercase and lowercase letters,
numbers, and special characters, it categorizes passwords as Weak, Medium, or Strong. This
function ensures that users create safer passwords, reducing the risk of hacking. Through
incremental development, we built and improved the function step by step, making debugging
easier. This project showcases practical problem-solving skills, making it a great addition to any
password practices.
11
Reference List
Downey, A. (2015). Think Python: How to think like a computer scientist. Needham,
Massachusetts: Green Tree Press. https://greenteapress.com/thinkpython2/thinkpython2.pdf