Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Programming Assignment Unit 4

This document outlines a programming assignment for developing functions using incremental development. It includes two parts: calculating the hypotenuse of a right triangle and creating a password strength checker, both requiring documentation of the development process. The assignment emphasizes debugging and showcases skills in problem-solving and cybersecurity.

Uploaded by

ashigull487
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Programming Assignment Unit 4

This document outlines a programming assignment for developing functions using incremental development. It includes two parts: calculating the hypotenuse of a right triangle and creating a password strength checker, both requiring documentation of the development process. The assignment emphasizes debugging and showcases skills in problem-solving and cybersecurity.

Uploaded by

ashigull487
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

1

Programming Assignment Unit 4

Ayesha Gul

University of the People

CS 1101: Programming Fundamentals

Dr Josiah Jolaoluwa

27th of February, 2025


2
Programming Assignment Unit 4

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

this assignment, and you must submit both parts.

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

different arguments and record the outputs in your Learning Journal.

Tasks

Include all of the following in your submission:

1.​ An explanation of each stage of development, including code and any test input

and output.

2.​ The output of hypotenuse(3,4).

3. The output of two additional calls to hypotenuse with different arguments.


3
Programming Assignment Unit 4

Answer:

Step 1: Understanding the Problem

The problem requires calculating the hypotenuse of a right triangle given the two other sides

(legs) using the Pythagorean Theorem:

c = √a2+b2

where c is the hypotenuse, and a and b are the two given sides.

Step 2: Writing the Basic Function

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.)

Step 3: Implementing the Square Root

To get the correct hypotenuse value, we now take the square root of a² + b²:

Output:

Step 4: Additional Testing

We now test the function with different values:


5
Programming Assignment Unit 4

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

potential clients and establish yourself as a freelancer.

As part of your portfolio, you plan to create your own function that does some useful

computation using an incremental development approach that will demonstrate your

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:

Function Idea: Password Strength Checker

A password strength checker is a useful function in cybersecurity applications. It evaluates a

given password and categorizes it as Weak, Medium, or Strong based on length and complexity.

Incremental Development Process:

Step 1: Basic Function Structure

We start by defining a function that accepts a password as input and returns its length.

Output:
7
Programming Assignment Unit 4

The functions show password length and no strength evaluation yet.

Step 2: Adding Basic Strength Rules

We define basic password strength rules:

1.​ Weak: Less than 6 characters.

2. ​ Medium: 6-10 characters.

3.​ Strong: More than 10 characters.

Output:
8
Programming Assignment Unit 4

Step 3: Adding Complexity Checks

Now, we check for:

1.​ Uppercase letters

2. ​ Lowercase letters

3. ​ Numbers

4.​ Special characters (@, #, $, etc.)


9
Programming Assignment Unit 4

Output:

Explanation of Fix:

The Strong category should only apply to passwords longer than 10 characters that also

include a special character.


10
Programming Assignment Unit 4

In the previous version, Strong@123 was not recognized as Strong because the check for

Medium came first.

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

programming portfolio. It highlights the importance of cybersecurity and encourages strong

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

You might also like