-
Notifications
You must be signed in to change notification settings - Fork 27
test attempted #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
test attempted #13
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def evaluate_performance(grades: list, min_pass: int): | ||||||||||||||||||||||||||||||||||||
|
|
@@ -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 = [] | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| grades = [] |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
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.
| 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
AI
Oct 27, 2025
There was a problem hiding this comment.
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.
| 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
AI
Oct 27, 2025
There was a problem hiding this comment.
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.
| for num in range(1, 25): | |
| for num in range(1, n+1): |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
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.
| for num in range(1, 25): | |
| for num in range(1, n+1): |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
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.
| 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
AI
Oct 27, 2025
There was a problem hiding this comment.
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.
| for num in range(1, 25): | |
| if num % 3 != 0: | |
| for num in range(1, length + 1): | |
| if num % n != 0: |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
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.
| nums = [] | |
| for num in nums: | |
| return max(num) | |
| pass | |
| if not nums: | |
| return None | |
| return max(nums) |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
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.
| print(skip_divisible_by_num(25, 6)) |
There was a problem hiding this comment.
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 likesum(i**2 for i in range(1, n+1)).