Skip to content
Open
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
58 changes: 57 additions & 1 deletion student_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def sum_of_squares(n: int):
Raises:
ValueError: If n is a negative integer.
"""
n >= 0
return sum(n ** 2)
pass
Comment on lines +15 to 17
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Line 15 performs a comparison but doesn't raise the documented ValueError for negative integers. Line 16 incorrectly computes n**2 instead of the sum of squares from 1 to n. Should validate n with if n < 0: raise ValueError(...) and compute the sum using a loop or formula like sum(i**2 for i in range(1, n+1)).

Suggested change
n >= 0
return sum(n ** 2)
pass
if n < 0:
raise ValueError("n must be a non-negative integer")
return sum(i ** 2 for i in range(1, n + 1))

Copilot uses AI. Check for mistakes.

def evaluate_performance(grades: list, min_pass: int):
Expand All @@ -25,6 +27,15 @@ def evaluate_performance(grades: list, min_pass: int):
Returns:
str: "Pass" if the average grade is greater than or equal to min_pass, otherwise "Fail".
"""
grades = []
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The function parameter grades is immediately overwritten with an empty list, discarding the input data needed for evaluation.

Suggested change
grades = []

Copilot uses AI. Check for mistakes.

for grade in grades:
if grade >= min_pass:
return "Pass"

if grade < min_pass:
return "Fail"

pass

Comment on lines +30 to 40
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The function returns on the first grade examined instead of computing the average of all grades. According to the docstring, it should calculate the average grade and compare that to min_pass.

Suggested change
grades = []
for grade in grades:
if grade >= min_pass:
return "Pass"
if grade < min_pass:
return "Fail"
pass
if not grades:
return "Fail"
average = sum(grades) / len(grades)
if average >= min_pass:
return "Pass"
else:
return "Fail"

Copilot uses AI. Check for mistakes.
def calculate_cumulative_performance(scores: dict):
Expand All @@ -37,6 +48,9 @@ def calculate_cumulative_performance(scores: dict):
Returns:
dict: A dictionary containing the average score and a list of subjects where the score is below average.
"""
scores = {}

return scores
pass

Comment on lines +51 to 55
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The function overwrites the input parameter scores with an empty dictionary and returns it, ignoring the input data. The function should calculate average score and identify below-average subjects from the input dictionary.

Suggested change
scores = {}
return scores
pass
if not scores:
return {"average": 0.0, "below_average_subjects": []}
average = sum(scores.values()) / len(scores)
below_average_subjects = [subject for subject, score in scores.items() if score < average]
return {"average": average, "below_average_subjects": below_average_subjects}

Copilot uses AI. Check for mistakes.
def analyze_improvement(scores: list):
Expand All @@ -62,6 +76,8 @@ def rank_students(students: list[tuple[str, int]]):
Returns:
list: A sorted list of tuples in descending order based on scores.
"""


pass

"""Learning Outcome: Basic Loops"""
Expand All @@ -75,6 +91,12 @@ def even_numbers(n: int):
Returns:
list: A list of even integers from 1 to n.
"""
numbers = []
for num in range(1, 25):
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Hardcoded range limit 25 ignores the function parameter n. Should use range(1, n+1) to respect the function's documented behavior.

Suggested change
for num in range(1, 25):
for num in range(1, n+1):

Copilot uses AI. Check for mistakes.
if num % 2 == 0:
numbers.append(num)

return numbers
pass

def odd_numbers(n: int):
Expand All @@ -87,6 +109,13 @@ def odd_numbers(n: int):
Returns:
list: A list of odd integers from 1 to n.
"""
numbers = []

for num in range(1, 25):
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Hardcoded range limit 25 ignores the function parameter n. Should use range(1, n+1) to respect the function's documented behavior.

Suggested change
for num in range(1, 25):
for num in range(1, n+1):

Copilot uses AI. Check for mistakes.
if num % 2 != 0:
numbers.append(num)

return numbers
pass

def sum_multiples_of_num(num: int, length: int):
Expand All @@ -100,6 +129,7 @@ def sum_multiples_of_num(num: int, length: int):
Returns:
int: The sum of multiples of num from 1 to length.
"""

pass

def skip_num(n: int, length: int):
Expand Down Expand Up @@ -138,6 +168,14 @@ def sum_numbers_until_zero(nums: list):
Returns:
int: The sum of integers in the list up to (but not including) the first zero.
"""
nums = []

for num in nums:
if num != 0:
nums.append(sum(nums))

return nums

Comment on lines +171 to +178
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The function overwrites the input parameter with an empty list, making the loop never execute. Additionally, line 175 appends sum(nums) instead of the individual number, and the function should return an integer sum, not a list.

Suggested change
nums = []
for num in nums:
if num != 0:
nums.append(sum(nums))
return nums
total = 0
for num in nums:
if num == 0:
break
total += num
return total

Copilot uses AI. Check for mistakes.
pass

def count_positive_numbers(nums: list):
Expand Down Expand Up @@ -187,6 +225,14 @@ def skip_divisible_by_num(n: int, length: int):
Returns:
list: A list of integers from 1 to length, excluding those divisible by n.
"""
numbers = []

for num in range(1, 25):
if num % 3 != 0:
Comment on lines +230 to +231
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Hardcoded values ignore function parameters. The range should use length+1 instead of 25, and the modulo check should use n instead of 3.

Suggested change
for num in range(1, 25):
if num % 3 != 0:
for num in range(1, length + 1):
if num % n != 0:

Copilot uses AI. Check for mistakes.
numbers.append(num)

return numbers

pass

"""Learning Outcome: Processing Data"""
Expand Down Expand Up @@ -282,6 +328,8 @@ def reverse_string(input: str):
Returns:
str: The reversed string.
"""

return input[::-1]
pass

def largest_number(nums: list[int]):
Expand All @@ -294,6 +342,10 @@ def largest_number(nums: list[int]):
Returns:
int or None: The largest number in the list, or None if the list is empty.
"""
nums = []

for num in nums:
return max(num)
pass

Comment on lines +345 to 350
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The function overwrites the input parameter with an empty list, making the loop never execute. The function should find the maximum value from the input list, which can be done with return max(nums) if nums else None.

Suggested change
nums = []
for num in nums:
return max(num)
pass
if not nums:
return None
return max(nums)

Copilot uses AI. Check for mistakes.
def is_prime(n: int):
Expand All @@ -319,4 +371,8 @@ def count_character_occurrences(word_sentence: str, char_count: str):
Returns:
int: The number of occurrences of the character in the sentence.
"""
pass
pass


print(skip_divisible_by_num(25, 6))
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Debug print statement left in production code. This should be removed or moved to a test file.

Suggested change
print(skip_divisible_by_num(25, 6))

Copilot uses AI. Check for mistakes.