Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./tests",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
74 changes: 74 additions & 0 deletions student_code.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"""Learning Outcome: Functions"""
def sum_of_squares(n: int):
if num <= 0:
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable name mismatch: the parameter is 'n' but the code references 'num'. This should be 'if n <= 0:'.

Suggested change
if num <= 0:
if n <= 0:

Copilot uses AI. Check for mistakes.
raise ValueError("Number cannot be a negative integer")
sum = 0
for num in range (1, n + 1):
sum += num * num
return sum
Comment on lines +6 to +8
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return statement is inside the loop, causing the function to return after the first iteration. Move 'return sum' outside the loop to calculate the complete sum of squares.

Copilot uses AI. Check for mistakes.
"""
Calculate the sum of the squares of all integers from 1 to n.

Expand All @@ -12,9 +18,21 @@ def sum_of_squares(n: int):
Raises:
ValueError: If n is a negative integer.
"""

pass

def evaluate_performance(grades: list, min_pass: int):
min_pass = 75
grades = []

Comment on lines +25 to +27
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function parameters are immediately overwritten with hardcoded values, discarding the input arguments. Remove these lines to use the actual parameters passed to the function.

Suggested change
min_pass = 75
grades = []

Copilot uses AI. Check for mistakes.
for grade in grades:
if grade >= min_pass:
return "Pass"
else:
return "Fail"
Comment on lines +28 to +32
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return statement inside the loop causes the function to return after checking only the first grade. This should likely accumulate results or return a list of pass/fail statuses for all grades.

Copilot uses AI. Check for mistakes.



"""
Evaluate the performance based on a list of grades and a minimum passing grade.

Expand All @@ -28,6 +46,11 @@ def evaluate_performance(grades: list, min_pass: int):
pass

def calculate_cumulative_performance(scores: dict):
average = sum[scores]/ len[scores]
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect syntax: 'sum' and 'len' are functions and require parentheses, not square brackets. This should be 'sum(scores) / len(scores)'. Additionally, 'scores' is a dict, so you likely need 'scores.values()'.

Suggested change
average = sum[scores]/ len[scores]
average = sum(scores.values()) / len(scores.values())

Copilot uses AI. Check for mistakes.




"""
Calculate the cumulative performance based on student scores.

Expand Down Expand Up @@ -66,6 +89,12 @@ def rank_students(students: list[tuple[str, int]]):

"""Learning Outcome: Basic Loops"""
def even_numbers(n: int):
evens = []
for num in range (1, n+1):
if num % 2 == 0:
evens.append(num)
return evens
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return statement is inside the loop, causing the function to return after finding the first even number. Move 'return evens' outside the loop.

Suggested change
return evens
return evens

Copilot uses AI. Check for mistakes.

"""
Generate a list of even numbers from 1 to n.

Expand All @@ -78,6 +107,11 @@ def even_numbers(n: int):
pass

def odd_numbers(n: int):
odds= []
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Missing space after variable name before '='. Should be 'odds = []' for consistent formatting.

Suggested change
odds= []
odds = []

Copilot uses AI. Check for mistakes.
for num in range (1, n+1):
if num % 2 != 0:
odds.append(num)
return odds
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return statement is inside the loop, causing the function to return after finding the first odd number. Move 'return odds' outside the loop.

Suggested change
return odds
return odds

Copilot uses AI. Check for mistakes.
"""
Generate a list of odd numbers from 1 to n.

Expand Down Expand Up @@ -192,6 +226,11 @@ def skip_divisible_by_num(n: int, length: int):
"""Learning Outcome: Processing Data"""

def square_numbers(nums: list):
nums = []
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input parameter 'nums' is overwritten with an empty list, discarding the actual input. Remove this line to process the provided list.

Suggested change
nums = []

Copilot uses AI. Check for mistakes.
squared = []
for num in nums:
num = num * num
return squared.append(num)
Comment on lines +231 to +233
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple issues: the squared values should be appended inside the loop (not returned), and the return should be outside the loop returning the 'squared' list. The 'append' method returns None, not the list.

Copilot uses AI. Check for mistakes.
"""
Calculate the square of each number in a list.

Expand All @@ -204,6 +243,7 @@ def square_numbers(nums: list):
pass

def transform_string(input: str, transform: str):

"""
Transform a string based on the specified transformation type.

Expand All @@ -220,6 +260,10 @@ def transform_string(input: str, transform: str):
pass

def sum_and_average(nums: list[int]):
nums = []
sum_and_average(nums)
return sum_and_average
Comment on lines +263 to +265
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recursive call creates infinite recursion and returns the function itself instead of a result. The function should calculate sum and average from the input 'nums' parameter without overwriting it.

Copilot uses AI. Check for mistakes.

"""
Calculate the sum and average of a list of numbers.

Expand All @@ -232,6 +276,11 @@ def sum_and_average(nums: list[int]):
pass

def word_frequency_count(words: list[str]):
words = []
word_count = 0

for w in words:
word_count += 1
Comment on lines +279 to +283
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'words' parameter is overwritten with an empty list, making the loop never execute. This also counts total words instead of word frequency. Remove line 279 and use a dictionary to count occurrences of each unique word.

Copilot uses AI. Check for mistakes.
"""
Count the frequency of each word in a list.

Expand All @@ -244,6 +293,12 @@ def word_frequency_count(words: list[str]):
pass

def filter_even_numbers(nums: list[int]):
nums = []
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input parameter 'nums' is overwritten with an empty list, discarding the actual input. Remove this line to process the provided list.

Suggested change
nums = []

Copilot uses AI. Check for mistakes.
even_integers = []
for num in nums:
if num % 2 == 0:
even_integers.append(num)
return even_integers
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return statement is inside the loop, causing the function to return after finding the first even number. Move 'return even_integers' outside the loop.

Suggested change
return even_integers
return even_integers

Copilot uses AI. Check for mistakes.
"""
Filter out even numbers from a list.

Expand All @@ -258,6 +313,10 @@ def filter_even_numbers(nums: list[int]):
"""Learning Outcome: Simple Algorithms(Problem Solving)"""

def find_median(nums: list[int]):
nums = []
median = sum(nums) / 2
return median
Comment on lines +316 to +318
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'nums' parameter is overwritten with an empty list, and median calculation is incorrect (dividing sum by 2 instead of finding the middle value). Remove line 316 and implement proper median logic by sorting the list and finding the middle element(s).

Suggested change
nums = []
median = sum(nums) / 2
return median
if not nums:
raise ValueError("The list is empty.")
nums_sorted = sorted(nums)
n = len(nums_sorted)
mid = n // 2
if n % 2 == 1:
return float(nums_sorted[mid])
else:
return (nums_sorted[mid - 1] + nums_sorted[mid]) / 2

Copilot uses AI. Check for mistakes.

"""
Find the median of a list of numbers.

Expand All @@ -273,6 +332,8 @@ def find_median(nums: list[int]):
pass

def reverse_string(input: str):

return reverse_string[::-1]
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable name error: 'reverse_string' is the function name, not the input parameter. This should be 'return input[::-1]'.

Suggested change
return reverse_string[::-1]
return input[::-1]

Copilot uses AI. Check for mistakes.
"""
Reverse the given string.

Expand All @@ -285,6 +346,8 @@ def reverse_string(input: str):
pass

def largest_number(nums: list[int]):
nums = []
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input parameter 'nums' is overwritten with an empty list, discarding the actual input. Remove this line to process the provided list.

Suggested change
nums = []

Copilot uses AI. Check for mistakes.

"""
Find the largest number in a list.

Expand All @@ -297,6 +360,11 @@ def largest_number(nums: list[int]):
pass

def is_prime(n: int):
for num in range(n):
if num // num == 1 and num // 1 == num:
return True
else:
return False
Comment on lines +363 to +367
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prime checking logic is incorrect. The condition 'num // num == 1' will cause division by zero when num=0, and the logic doesn't properly test for prime numbers. A prime number should only be divisible by 1 and itself; implement proper divisibility testing.

Suggested change
for num in range(n):
if num // num == 1 and num // 1 == num:
return True
else:
return False
if n < 2:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True

Copilot uses AI. Check for mistakes.
"""
Check if a number is prime.

Expand All @@ -309,6 +377,12 @@ def is_prime(n: int):
pass

def count_character_occurrences(word_sentence: str, char_count: str):
word_sentence = ""
char_count = 0

for char in word_sentence:
char_count += 1
return char_count
Comment on lines +380 to +385
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'word_sentence' parameter is overwritten with an empty string, making the loop never execute. The function should count occurrences of the specific character 'char_count' (second parameter) in 'word_sentence', not total character count. Remove lines 380-381 and implement proper character counting logic.

Copilot uses AI. Check for mistakes.
"""
Count the occurrences of a character in a given sentence.

Expand Down