Benefits of Collaboration Within a Team

Having a team can make the creation of a project faster and more efficient. With each task given to a group member, the project can be done with more detail due to each section being worked on specifically by one person while also being done at a faster rate. Collaboration is also important because groups can easily be off-task and not do the work they’re supposed to do if there is a lack of collaboration. But when done right, a collaborating group can facilitate their project and manage each member’s task, leading to an easier and more successful project.

Diversities of our team: One of the diversities our team has is in its software; half of our scrum team work on Macs while the other half works on Windows computers. This can help reduce the chances of everyone having the same problem on one platform. In additon we all have differnt levels of expertise in coding, allowing for everyone to help eachother on thier respective needs.

How will you hold each person accountable for their portion of the work?: We will ulitlize a system, of checks and balances, were we check eathothers work to make sure that we are all doing what is expected

Programs with Ouput

Programs with output give a one-way display to the user (ex: displaying text):

print("This message is only output!")
This message is only output!

Program with Input and Output

Programs with both input and ouput take into account a user’s response and answers back with an ouput (ex: python quizzes/surveys):

def question_and_response(prompt):
    print("Question: " + prompt)
    rsp=input("Your Answer:")
    return rsp
questions=1

rsp=question_and_response("Hi, how is your day going? good or bad?")
if rsp=="good":
    print("That's nice to hear!")
else:
    print("Oh no, I'm sorry to hear that.")
Question: Hi, how is your day going? good or bad?
Oh no, I'm sorry to hear that.

Program with a List

A program that uses a list data structure to store a group of elements.

# Create a list of something
shopping_list = []
# Function to add something to the list
def add_to_list(item):
    shopping_list.append(item)
    print(f"Added '{item}' to the shopping list.")
# Function to remove something from the list
def remove_from_list(item):
    if item in shopping_list:
        shopping_list.remove(item)
        print(f"Removed '{item}' from the shopping list.")
# Example usage:
add_to_list("Apples")
add_to_list("Bananas")
remove_from_list("Apples")
Added 'Apples' to the shopping list.
Added 'Bananas' to the shopping list.
Removed 'Apples' from the shopping list.

Program with a Dictionary

## Program with a Dictionary
#A dictionary allows you to store and retrieve key-value pairs.
# Create a dictionary
student_scores = {
    "Alice": 95,
    "Bob": 89,
}
# Retrieve the values that are assigned
alice_score = student_scores["Alice"]
bob_score = student_scores["Bob"]
# Print the scores
print("Alice's score:", alice_score)
print("Bob's score:", bob_score)
##"student_scores" is a python dictionary that associates the students with their scores. Alice and Bob are the keys and the scores they got are the values, therefore creating a key-value pair.

Alice's score: 95
Bob's score: 89

Program with Iteration

# Calculate the sum of numbers in a list using a for loop
# Define a list of numbers
numbers = [1, 2, 3, 4, 5]
# Initialize a variable to store the sum
sum_of_numbers = 0
# Iterate over the list and calculate the sum
for number in numbers:
    sum_of_numbers += number
# Print the sum
print("The sum of numbers is:", sum_of_numbers)
The sum of numbers is: 15

Program with Function to Perform Mathematical/Statistical Calculations

# adding
def add(x, y):
    return x + y
# subtracting
def subtract(x, y):
    return x - y
# multiply
def multiply(x, y):
    return x * y
# division
def divide(x, y):
    if y == 0:
        return "Can't divide by zero"
    return x / y
# display operations
print("Select operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
# choose whether to add, subtract, multipy, divide
choice = input("Enter choice (1/2/3/4): ")
# choose your numbers
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
# preform the selcted operation
if choice == '1':
    result = add(num1, num2)
    print("Result: ", result)
elif choice == '2':
    result = subtract(num1, num2)
    print("Result: ", result)
elif choice == '3':
    result = multiply(num1, num2)
    print("Result: ", result)
elif choice == '4':
    result = divide(num1, num2)
    print("Result: ", result)
else:
    print("Invalid input")
Select operation:
1. Add
2. Subtract
3. Multiply
4. Divide


Result:  40.0

Program with Selection/Condition

These are programs or sections of code that include decision-making logic based on certain conditions or criteria. These conditions are typically expressed using conditional statements (e.g., if statements) that allow the program to take different actions or follow different paths of execution based on the evaluation of these conditions:

age=int(input("Enter your age: ")) 
if age >= 18:
    print("You are eligible to vote.") 
else: print("You are not eligible to vote yet.") 
You are not eligible to vote yet.

Program with Purpose

# Function to calculate the factorial of a number
def factorial(n):
    if n == 0:
        return 1
    else:
        result = 1
        for i in range(1, n + 1):
            result *= i
        return result

# Input: Prompt the user to enter a number
num = int(input("Enter a number: "))

# Calculate the factorial
result = factorial(num)

# Output: Display the factorial of the number
print(f"The factorial of {num} is {result}")
The factorial of 2 is 2

Program Design and Development

Here is a hangman program before we have expanded on it:

#!/usr/bin/python3
# Hangman game

import random

class HangMan(object):
    
    # Hangman game
    hang = []
    hang.append(' +---+')
    hang.append(' |   |')
    hang.append('     |')
    hang.append('     |')
    hang.append('     |')
    hang.append('     |')
    hang.append('=======')
    
    man = {}
    man[0] = [' 0   |']
    man[1] = [' 0   |', ' |   |']
    man[2] = [' 0   |', '/|   |']
    man[3] = [' 0   |', '/|\\  |']
    man[4] = [' 0   |', '/|\\  |', '/    |']
    man[5] = [' 0   |', '/|\\  |', '/ \\  |']
    
    pics = []
    
    words = '''ant baboon badger bat bear beaver camel cat clam cobra cougar coyote
crow deer dog donkey duck eagle ferret fox frog goat goose hawk lion lizard llama
mole monkey moose mouse mule newt otter owl panda parrot pigeon python rabbit ram
rat raven rhino salmon seal shark sheep skunk sloth snake spider stork swan tiger
toad trout turkey turtle weasel whale wolf wombat zebra'''.split()

    infStr='_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\''
  
    def __init__(self, *args, **kwargs):
        i, j = 2, 0
        self.pics.append(self.hang[:])
        for ls in self.man.values():
            pic, j = self.hang[:], 0
            for m in ls:
                pic[i + j] = m
                j += 1
            self.pics.append(pic)

    def pickWord(self):
        return self.words[random.randint(0, len(self.words) - 1)]
    
    def printPic(self, idx, wordLen):
        for line in self.pics[idx]:
            print(line)
            
    def askAndEvaluate(self, word, result, missed):
        guess = input()
        if guess == None or len(guess) != 1 or (guess in result) or (guess in missed):
            return None, False
        i = 0
        right = guess in word
        for c in word:
            if c == guess:
                result[i] = c
            i += 1
        return guess, right

    def info(self, info):
        ln=len(self.infStr)
        print(self.infStr[:-3])
        print(info)
        print(self.infStr[3:])
            
    def start(self):
        print('Welcome to Hangman !')
        word = list(self.pickWord())
        result = list('*' * len(word))
        print('The word is: ', result)
        success, i, missed = False, 0, []
        while i < len(self.pics)-1:
            print('Guess the word: ', end='')
            guess,right = self.askAndEvaluate(word, result, missed)
            if guess == None:
                print('You\'ve already entered this character.')
                continue
            print(''.join(result))
            if result == word:
                self.info('Congratulations ! You\'ve just saved a life !')
                success = True
                break
            if not right:
                missed.append(guess)
                i+=1
            self.printPic(i, len(word))
            print('Missed characters: ', missed)
        
        if not success:
            self.info('The word was \''+''.join(word)+'\' ! You\'ve just killed a man, yo !')

a = HangMan().start()

Now here is the version that we have expanded on and explained:

#!/usr/bin/python3
# Hangman game

import random

###Change made: added hint list for animal categories
category_hints = {
    'clam': 'Sea',
    'salmon': 'Sea',
    'seal': 'Sea',
    'shark': 'Sea',
    'trout': 'Sea',
    'whale': 'Sea',
    'baboon': 'Land',
    'badger': 'Land',
    'bat': 'Land',
    'bear': 'Land',
    'beaver': 'Land',
    'camel': 'Land',
    'cat': 'Land',
    'cobra': 'Land',
    'cougar': 'Land',
    'coyote': 'Land',
    'crow': 'Land',
    'deer': 'Land',
    'dog': 'Land',
    'donkey': 'Land',
    'duck': 'Land (ability to fly)',
    'eagle': 'Land (ability to fly)',
    'ferret': 'Land',
    'fox': 'Land',
    'frog': 'Land',
    'goat': 'Land',
    'goose': 'Land',
    'hawk': 'Land (ability to fly)',
    'lion': 'Land',
    'lizard': 'Land',
    'llama': 'Land',
    'mole': 'Land',
    'monkey': 'Land',
    'moose': 'Land',
    'mouse': 'Land',
    'mule': 'Land',
    'newt': 'Land',
    'otter': 'Land',
    'owl': 'Land',
    'panda': 'Land',
    'parrot': 'Land',
    'pigeon': 'Land (ability to fly)',
    'python': 'Land',
    'rabbit': 'Land',
    'ram': 'Land',
    'rat': 'Land',
    'raven': 'Land',
    'rhino': 'Land',
    'sheep': 'Land',
    'skunk': 'Land',
    'sloth': 'Land',
    'snake': 'Land',
    'stork': 'Land (ability to fly)',
    'swan': 'Land (ability to fly)',
    'tiger': 'Land',
    'toad': 'Land',
    'turkey': 'Land (ability to fly)',
    'turtle': 'Land',
    'weasel': 'Land',
    'wolf': 'Land',
    'wombat': 'Land',
    'zebra': 'Land',
    'ant': 'Bugs/Insects',
    'spider': 'Bugs/Insects',
}

class HangMan(object):
    
    # Hangman game
    ###Change made: bigger stage
    hang = []
    hang.append(' +------------+')
    hang.append(' |            |')
    hang.append('              |')
    hang.append('              |')
    hang.append('              |')
    hang.append('              |')
    hang.append('================')
    
    man = {}
    man[0] = [' 0            |']
    man[1] = [' 0            |', ' |            |']
    man[2] = [' 0            |', '/|            |']
    man[3] = [' 0            |', '/|\\           |']
    man[4] = [' 0            |', '/|\\           |', '/             |']
    man[5] = [' 0            |', '/|\\           |', '/ \\           |']
    
    pics = []
    
    ###Lists possible answer words for the game
    words = '''ant baboon badger bat bear beaver camel cat clam cobra cougar coyote
crow deer dog donkey duck eagle ferret fox frog goat goose hawk lion lizard llama
mole monkey moose mouse mule newt otter owl panda parrot pigeon python rabbit ram
rat raven rhino salmon seal shark sheep skunk sloth snake spider stork swan tiger
toad trout turkey turtle weasel whale wolf wombat zebra'''.split()

    infStr='_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\'*-_-*\''
  
    def __init__(self, *args, **kwargs):
        i, j = 2, 0
        self.pics.append(self.hang[:])
        for ls in self.man.values():
            pic, j = self.hang[:], 0
            for m in ls:
                pic[i + j] = m
                j += 1
            self.pics.append(pic)

    def pickWord(self):
        return self.words[random.randint(0, len(self.words) - 1)]
    
    def printPic(self, idx, wordLen):
        for line in self.pics[idx]:
            print(line)
            
            ###Defines function which asks the user to guess a letter and evaluates to see if they were correct.
    def askAndEvaluate(self, word, result, missed):
        guess = input()
        if guess == None or len(guess) != 1 or (guess in result) or (guess in missed):
            return None, False
        i = 0
        right = guess in word
        for c in word:
            if c == guess:
                result[i] = c
            i += 1
        return guess, right

    def info(self, info):
        ln=len(self.infStr)
        print(self.infStr[:-3])
        print(info)
        print(self.infStr[3:])
       ###Starts the hangman game     
    def start(self):
        print('Welcome to Hangman, these words are in the animal category !') ###Change: more descriptive intro sentence
        word = list(self.pickWord())
        result = list('*' * len(word))
        print('The word is: ', result)
        success, i, missed = False, 0, []
        while i < len(self.pics)-1:
            print('Guess the word: ', end='')
            guess,right = self.askAndEvaluate(word, result, missed)
            if guess == None:
                print('You\'ve already entered this character.')
                continue
            print(''.join(result))
            if result == word: ###If/else conditions which either congratulate user for right answer or add appendage for wrong answer
                self.info('Congratulations ! You\'ve just saved a life !')
                success = True
                break
            if not right:
                missed.append(guess)
                i+=1
            self.printPic(i, len(word))
            print('Missed characters: ', missed)
            
            ###Change made: added hint after every wrong answer to help user
            if i < len(self.pics) - 1:
                word_category = category_hints.get(''.join(word), 'No category available.')
                print('Hint:', word_category)        
        if not success:
            self.info('The word was \''+''.join(word)+'\' ! You\'ve just killed a man, yo !')

a = HangMan().start()

Documentation of Programs with Lists and Iteration

###List of the numbers that are being evaluated
numbers= [90,81,75,63,82,40,25,46,54,30,55,1035,900]

Factors_of_5=0 ###Gives the program a starting value for how many factors of 5 there are in the list

###Adds 1 to total factors of 5 if the remainder (%) of the number when divided by 5 is 0
for num in numbers:
    if num % 5==0:
        Factors_of_5 +=1
      
###Prints out final text including the string counting the factors of 5 in the list of numbers alog with text       
print("There are " + str(Factors_of_5) + " factors of 5 in this list.")
There are 8 factors of 5 in this list.

Comments on a Program with Mathematical/Statistical Calculation

## Simple calculator

# Function for adding two numbers
def add(x, y):
    return x + y

# Function for subtracting two numbers
def subtract(x, y):
    return x - y

# Function for multiplying two numbers
def multiply(x, y):
    return x * y

# Function for dividing two numbers, with a check for division by zero
def divide(x, y):
    if y == 0:
        return "Can't divide by zero"
    return x / y

# Display available operations to the user
print("Select operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")

# User input: choose the desired operation
choice = input("Enter choice (1/2/3/4): ")

# User input: enter the first and second numbers for the operation
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

# Perform the selected operation based on the user's choice
if choice == '1':
    result = add(num1, num2)
    print("Result: ", result)
elif choice == '2':
    result = subtract(num1, num2)
    print("Result: ", result)
elif choice == '3':
    result = multiply(num1, num2)
    print("Result: ", result)
elif choice == '4':
    result = divide(num1, num2)
    print("Result: ", result)
else:
    print("Invalid input")

Identifying and Correcting Errors

These are programs that help reduce errors when inputting information:

If/Else statements: These statements are clear and well structured. They’re easy to read and use and reduce the chances of errors. If/else statements handle errors nicely as you can check if the output is working which reduces the chance of unexpected behaviors such as crashes.

## Show comments and code logic that reduces errors in code with if / else statements.
# Check if a person can vote based on age
# Input: age - an integer representing a person's age
age = int(input("Enter your age: "))
# Define the minimum voting age
voting_age = 18
# Use an if/else statement to check if the person can vote
if age >= voting_age:
    print("You are eligible to vote.")
else:
    print("You are not eligible to vote yet. Please wait until you are 18 or older.")
You are not eligible to vote yet. Please wait until you are 18 or older.

Try/Except Statements: These statements help keep code running in case an initial input doesn’t work. The try is the intial function and the except is the function that runs if an error occurs.

import math
###This example results in a successful input and output with 
try:
    number=25
    result= math.sqrt(number)
    print(f"The square root of {number} is {result}")
    
except ValueError as e:
    print(f"Error: {e}")
The square root of 25 is 5.0
import math

try:
    number=-43
    result= math.sqrt(number)
    print(f"The square root of {number} is {result}")
    
except ValueError as e:
    print(f"Error: {e}")
Error: math domain error