-
Notifications
You must be signed in to change notification settings - Fork 27
Ayanda #5
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?
Ayanda #5
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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "python.testing.unittestArgs": [ | ||
| "-v", | ||
| "-s", | ||
| "./tests", | ||
| "-p", | ||
| "test_*.py" | ||
| ], | ||
| "python.testing.pytestEnabled": false, | ||
| "python.testing.unittestEnabled": true | ||
| } |
| 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: | ||||||||||||||||||||||||||
| 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
|
||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||
| Calculate the sum of the squares of all integers from 1 to n. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -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
|
||||||||||||||||||||||||||
| min_pass = 75 | |
| grades = [] |
Copilot
AI
Oct 21, 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 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
AI
Oct 21, 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.
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()'.
| average = sum[scores]/ len[scores] | |
| average = sum(scores.values()) / len(scores.values()) |
Copilot
AI
Oct 21, 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 return statement is inside the loop, causing the function to return after finding the first even number. Move 'return evens' outside the loop.
| return evens | |
| return evens |
Copilot
AI
Oct 21, 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.
[nitpick] Missing space after variable name before '='. Should be 'odds = []' for consistent formatting.
| odds= [] | |
| odds = [] |
Copilot
AI
Oct 21, 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 return statement is inside the loop, causing the function to return after finding the first odd number. Move 'return odds' outside the loop.
| return odds | |
| return odds |
Copilot
AI
Oct 21, 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 input parameter 'nums' is overwritten with an empty list, discarding the actual input. Remove this line to process the provided list.
| nums = [] |
Copilot
AI
Oct 21, 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.
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
AI
Oct 21, 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.
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
AI
Oct 21, 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 '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
AI
Oct 21, 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 input parameter 'nums' is overwritten with an empty list, discarding the actual input. Remove this line to process the provided list.
| nums = [] |
Copilot
AI
Oct 21, 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 return statement is inside the loop, causing the function to return after finding the first even number. Move 'return even_integers' outside the loop.
| return even_integers | |
| return even_integers |
Copilot
AI
Oct 21, 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 '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).
| 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
AI
Oct 21, 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.
Variable name error: 'reverse_string' is the function name, not the input parameter. This should be 'return input[::-1]'.
| return reverse_string[::-1] | |
| return input[::-1] |
Copilot
AI
Oct 21, 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 input parameter 'nums' is overwritten with an empty list, discarding the actual input. Remove this line to process the provided list.
| nums = [] |
Copilot
AI
Oct 21, 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 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.
| 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
AI
Oct 21, 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 '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.
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.
Variable name mismatch: the parameter is 'n' but the code references 'num'. This should be 'if n <= 0:'.