0% found this document useful (0 votes)
45 views11 pages

Unit 4 Programming Assignments Overview

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views11 pages

Unit 4 Programming Assignments Overview

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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. [Link]

Common questions

Powered by AI

Engaging in incremental software development projects provides educational benefits by enhancing problem-solving skills, understanding of programming concepts, and attention to detail. These projects teach students how to break down complex problems into manageable parts, fostering a step-by-step approach to development that emphasizes gradual improvement and iterative testing. This methodology not only improves coding skills but also cultivates a mindset geared towards continuous reflection and correction, mirroring real-world software development and preparing students for professional challenges .

Incremental development assists in debugging by allowing developers to build and test the function step-by-step. This method enables the identification and correction of errors at each stage of development, preventing errors from compounding and making troubleshooting more manageable. For example, in developing the hypotenuse calculator, each step—such as writing the basic function and then adding the square root operation—was validated before proceeding to the next stage, ensuring each part worked correctly before being integrated into the larger program .

Documenting each stage of development is significant because it provides a clear and organized record of the development process, which aids in understanding, communication, and maintenance. It ensures that each step from problem understanding, initial code writing, testing, and final verification is tracked, which can be referred back to for debugging or further development. Moreover, it helps in assessing the workflow efficiency and facilitates knowledge transfer, making it easier for others to understand the process and contribute to or modify the project .

The password strength checker was developed using an incremental development approach, which involves building and refining the function step-by-step. This method is beneficial for cybersecurity applications because it allows for the function's logic to be systematically tested and improved, ensuring robustness and reliability. By incrementally adding features such as length evaluation and complexity checks—like the presence of uppercase, lowercase, numbers, and special characters—it ensures comprehensive evaluation of password strength, thereby improving security by encouraging users to create stronger passwords .

The categorization of passwords into Weak, Medium, or Strong categories is determined by length and complexity. A password is considered Weak if it has less than 6 characters, Medium if it is 6-10 characters long, and Strong if it is more than 10 characters long. Furthermore, for a password to be considered Strong, it must also include a special character, ensuring it meets additional complexity requirements beyond length alone .

Checking for both length and special characters in the password strength checker is significant because it combines two key aspects of password security—complexity and unpredictability. Length provides a basic defense against brute force attacks by increasing the number of possible combinations, while special characters add complexity, making passwords harder to guess or crack through automated techniques. Omitting checks for either factor could significantly compromise security; a long password without special characters may be susceptible to dictionary attacks, while a short password with special characters might not withstand a brute force attack due to limited complexity. Therefore, incorporating both ensures comprehensive evaluation of password strength .

The order of conditions in the password strength checker affects functionality by determining which categorization logic executes first, which in turn ensures correct category assignment. Initially, 'Medium' passwords were identified before checking for 'Strong', causing certain strong passwords that met less strict criteria earlier to be incorrectly labeled. Revising the order so that conditions for 'Strong' are checked first ensures that all passwords meeting the strictest criteria, such as length and complexity including a special character, are correctly categorized as 'Strong'. This ordering ensures evaluation based on hierarchy of strength rather than first match, enhancing accuracy in classification .

The hypotenuse function is tested by executing it with various pairs of sides and checking the accuracy of its outputs. For instance, it is tested with the sides (3, 4) which should return 5, as 5 is the hypotenuse when 3 and 4 are legs of a right triangle (since 3² + 4² = 9 + 16 = 25, and √25 = 5). Testing is crucial because it verifies that the function works as intended and handles all edge cases, ensuring reliability and correctness before deployment. This process helps catch errors early and provides confidence in the function's correctness .

Using incremental development for portfolio projects can significantly enhance a programmer's career prospects by demonstrating proficiency in methodical and thoughtful software design. This approach showcases the individual's ability to thoroughly understand and tackle complex tasks systematically, revealing their skills in debugging and optimizing code. Additionally, a portfolio that displays incremental progress highlights a commitment to quality and attention to detail, characteristics highly valued in the industry. For potential employers or clients, such a portfolio suggests that the programmer is capable of delivering reliable software solutions and adapting to varying project requirements .

Requiring more than just length for the 'Strong' category in password evaluation is critical because password complexity reduces the risk of unauthorized access. While a long password may seem secure, without including uppercase letters, lowercase letters, numbers, and special characters, it can still be vulnerable to certain types of attacks, such as dictionary attacks. Therefore, the additional requirement for a special character ensures that the password has layered complexity, making it significantly harder for attackers to compromise through guesses or simple brute force methods .

You might also like