Prashely the GOAT#14
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements multiple Python functions for educational purposes, focusing on functions, loops, data processing, and simple algorithms. The changes replace placeholder pass statements with working implementations across various learning outcomes.
Key Changes:
- Implementation of 20+ functions covering mathematical operations, list processing, and string manipulation
- Addition of a practice file demonstrating the
rank_studentsfunction - Configuration of VS Code settings for Python unit testing
Reviewed Changes
Copilot reviewed 3 out of 10 changed files in this pull request and generated 17 comments.
| File | Description |
|---|---|
| tests/pycache/student_code.py | Implements all function bodies replacing pass statements with working code for loops, data processing, and algorithms |
| practice.py | Adds a practice/test file for the rank_students function |
| .vscode/settings.json | Configures Python unit testing with unittest framework |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """ | ||
| pass | ||
| if n < 0: | ||
| return ValueError |
There was a problem hiding this comment.
The function should raise ValueError, not return it. Change return ValueError to raise ValueError('n must be non-negative') or similar error message.
| return ValueError | |
| raise ValueError("n must be non-negative") |
| if n < 0: | ||
| return ValueError | ||
| total = 0 | ||
| for i in range(n): |
There was a problem hiding this comment.
The loop uses range(n) which iterates from 0 to n-1, but the docstring specifies calculating the sum from 1 to n (inclusive). Change to range(1, n + 1) to match the specification.
| for i in range(n): | |
| for i in range(1, n + 1): |
| for grade in grades: | ||
| if grade >= min_pass: | ||
| return "Pass" | ||
| else: | ||
| return "False" |
There was a problem hiding this comment.
The function returns immediately after checking the first grade instead of evaluating the average of all grades. According to the docstring, it should calculate the average grade and compare it to min_pass. The return value should also be 'Fail' not 'False'.
| for grade in grades: | |
| if grade >= min_pass: | |
| return "Pass" | |
| else: | |
| return "False" | |
| if not grades: | |
| return "Fail" | |
| average = sum(grades) / len(grades) | |
| if average >= min_pass: | |
| return "Pass" | |
| else: | |
| return "Fail" |
| """ | ||
| pass | ||
|
|
||
| return sorted(students[1]) |
There was a problem hiding this comment.
This attempts to access index [1] on a list and sort it, which is incorrect. The function should sort the entire students list by score in descending order. Use return sorted(students, key=lambda x: x[1], reverse=True).
| return sorted(students[1]) | |
| return sorted(students, key=lambda x: x[1], reverse=True) |
| odd_numbers = [] | ||
| for i in range(n): | ||
| if i % 2 != 0: | ||
| odd_numbers.append(i) | ||
| """ |
There was a problem hiding this comment.
The function implementation appears before its docstring. Move lines 135-137 to after line 147 (after the docstring). Additionally, the range should be range(1, n+1) to match the 'from 1 to n' specification in the docstring.
| return statistics.median(nums) | ||
| """ |
There was a problem hiding this comment.
The function implementation appears before its docstring, and there's a pass statement after the docstring. Move line 396 to replace line 409 (the pass statement).
| if len(nums) == 0: | ||
| return None | ||
| else: | ||
| nums = sorted(nums) | ||
| largest_number = nums[-1] | ||
| """ |
There was a problem hiding this comment.
The function implementation appears before its docstring. Move lines 423-427 to after line 436 (after the docstring).
| factors = [] | ||
| for i in range(1, n+1): | ||
| if n % i == 0: | ||
| factors.append(i) | ||
| if len(factors) == 2: | ||
| return True | ||
| else: | ||
| return False | ||
| """ |
There was a problem hiding this comment.
The function implementation appears before its docstring. Move lines 439-446 to after line 455 (after the docstring).
| char_counter = 0 | ||
|
|
||
| for el in word_sentence: | ||
| if el == char_count: | ||
| char_counter += 1 | ||
| """ |
There was a problem hiding this comment.
The function implementation appears before its docstring. Move lines 460-464 to after line 474 (after the docstring).
| list: A sorted list of tuples in descending order based on scores. | ||
| """ | ||
|
|
||
| return sorted(students) |
There was a problem hiding this comment.
The function sorts students by name (alphabetically) instead of by score in descending order. Use return sorted(students, key=lambda x: x[1], reverse=True) to sort by score.
| return sorted(students) | |
| return sorted(students, key=lambda x: x[1], reverse=True) |
No description provided.