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

Unit 4 Programming Assignment Overview

The document outlines a programming assignment for CS 1101 at the University of the People, focusing on developing functions through incremental development. It consists of two parts: calculating the hypotenuse of a right triangle and creating a password strength checker, with detailed steps for each function's development process. The assignment emphasizes documentation, testing, and showcases the importance of cybersecurity in programming.

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)
28 views11 pages

Unit 4 Programming Assignment Overview

The document outlines a programming assignment for CS 1101 at the University of the People, focusing on developing functions through incremental development. It consists of two parts: calculating the hypotenuse of a right triangle and creating a password strength checker, with detailed steps for each function's development process. The assignment emphasizes documentation, testing, and showcases the importance of cybersecurity in programming.

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

The function development process exemplifies problem-solving and debugging skills by requiring the developer to first comprehensively understand the problem, then incrementally build and test each component of the function . This methodical approach ensures that problems are identified as soon as they arise and facilitates debugging, as each stage of development is thoroughly tested and documented. Debugging becomes an ongoing activity rather than an afterthought, highlighting a pragmatic problem-solving methodology intrinsic to successful software development .

The password strength checker starts by defining a function that takes a password as input and returns its length, which serves as the basic structure . Next, incremental rules are added to categorize passwords based on length: less than 6 characters is 'Weak,' 6-10 characters is 'Medium,' and longer than 10 is 'Strong' . Additionally, checks for uppercase letters, lowercase letters, numbers, and special characters were added to enhance complexity evaluation . Finally, the function was adjusted to ensure the 'Strong' category only applies if a password is both longer than 10 characters and includes a special character, resolving previous logic issues .

The hypotenuse function illustrates the application of fundamental mathematical principles in programming by directly implementing the Pythagorean Theorem to solve a real-world problem—calculating the hypotenuse of a right triangle . It demonstrates how mathematical formulas can be translated into code and how logical and theoretical mathematical concepts are applied in a computational context. This marriage of mathematical principles and programming underscores the importance of foundational math skills in developing practical software solutions .

The order of conditions in the password strength checker impacts the evaluation because the checks are sequential, meaning earlier checks can exclude later conditions from being evaluated . For instance, initially, a password like 'Strong@123' was not categorized as 'Strong' because the 'Medium' check, which came first, had already categorized it before the 'Strong' condition could be evaluated . Reordering the conditions to check for 'Strong' passwords first resolved this issue, ensuring all conditions are appropriately evaluated before categorization .

Incremental development involves breaking down the process of creating a function into small, manageable steps and developing them sequentially while constantly testing and adjusting. For the hypotenuse function, this began with understanding the problem requirements and the Pythagorean theorem . Next, a basic function to calculate the sum of squares of the two sides was created . This was followed by implementing the square root calculation to get the hypotenuse value . Finally, the function was thoroughly tested with different inputs to ensure accuracy .

Rearranging conditions in a logical structure is crucial because it determines the control flow of the program and ensures that all necessary evaluations are performed correctly and efficiently . In the password strength checker, initially, conditions were ordered such that the medium and strong evaluations led to incorrect categorizations because they were evaluated sequentially in a manner that prematurely categorized passwords . By reordering the conditions to evaluate the 'Strong' password criteria first, the function correctly classified passwords meeting all specific criteria, ensuring accurate and logical outcomes .

Challenges in incremental development include ensuring each stage builds correctly on the previous one, identifying inherent problems early, and maintaining clean and understandable code . These challenges can be mitigated by thorough testing at each stage to catch errors early, involved documentation to keep track of changes, and regular code reviews to maintain quality and coherence . Additionally, designing test cases that are comprehensive enough to cover edge cases can help anticipate potential future problems .

Developing a personal software portfolio using an incremental development approach offers insights into one's programming skills and versatility by showcasing the ability to handle complex tasks through systematic breakdowns and gradual refinements . It demonstrates a developer's capacity to manage projects methodically, adapt to new challenges by solving them in manageable steps, and portrays a disciplined approach to building software solutions. Such a process also highlights problem-solving and critical thinking abilities, crucial for establishing credibility and attracting potential clients in the field of freelance software development .

Incremental development facilitates debugging compared to traditional development methods by breaking the development process into smaller, tested components, allowing for immediate identification and correction of errors at each stage . This contrasts with traditional methods where debugging occurs after attempting to implement a complete solution, potentially allowing errors to propagate through the entire system, making them harder to isolate and fix . Incremental development embeds debugging within the development cycle, thereby reducing the severity and complexity of bugs and leading to more robust software outcomes .

Documenting each stage of the development process is critical because it provides a clear roadmap of what has been accomplished, helps in identifying errors or bugs at specific stages, and facilitates easier debugging . It also ensures that any changes made during the development process are traceable, and the rationale behind each decision is recorded, which is essential for maintaining the program or when future updates are needed .

You might also like