Skip to content

test attempted#13

Open
KeaMokoena-codes wants to merge 1 commit into
micanipho:mainfrom
KeaMokoena-codes:main
Open

test attempted#13
KeaMokoena-codes wants to merge 1 commit into
micanipho:mainfrom
KeaMokoena-codes:main

Conversation

@KeaMokoena-codes
Copy link
Copy Markdown

No description provided.

@micanipho micanipho requested a review from Copilot October 27, 2025 14:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR contains multiple attempted function implementations in a student code file. The changes add basic logic to several previously unimplemented functions, though many implementations contain errors or don't properly use their function parameters.

Key Changes:

  • Added implementations for mathematical functions (sum_of_squares, evaluate_performance)
  • Added implementations for list generation functions (even_numbers, odd_numbers, skip_divisible_by_num)
  • Added implementations for utility functions (reverse_string, largest_number)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread student_code.py
Comment on lines +15 to 17
n >= 0
return sum(n ** 2)
pass
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.
Comment thread student_code.py
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.
Comment thread student_code.py
Comment on lines +30 to 40
grades = []

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

if grade < min_pass:
return "Fail"

pass

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.
Comment thread student_code.py
Comment on lines +51 to 55
scores = {}

return scores
pass

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.
Comment thread student_code.py
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.
Comment thread student_code.py
"""
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.
Comment thread student_code.py
Comment on lines +171 to +178
nums = []

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

return nums

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.
Comment thread student_code.py
Comment on lines +230 to +231
for num in range(1, 25):
if num % 3 != 0:
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.
Comment thread student_code.py
Comment on lines +345 to 350
nums = []

for num in nums:
return max(num)
pass

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.
Comment thread student_code.py
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants