Lauren Steenkamp#10
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements several previously stubbed-out functions in student_code.py, including mathematical calculations, grade evaluation, performance analysis, and number filtering utilities.
Key Changes:
- Implementation of mathematical functions (
sum_of_squares,even_numbers,odd_numbers) - Implementation of grade/performance evaluation functions (
evaluate_performance,calculate_cumulative_performance,analyze_improvement) - Addition of debug print statements at module level
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else: | ||
| for i in range(1, n + 1): | ||
| total+= (i** 2) | ||
| return print(total) |
There was a problem hiding this comment.
The function returns the result of print(total) which is None, instead of returning the actual total value. Remove print() and return total directly to match the documented return type of int.
| return print(total) | |
| return total |
| print(sum_of_squares(100)) | ||
|
|
||
|
|
There was a problem hiding this comment.
Module-level print statement should be removed. This creates side effects when the module is imported and is not part of the function's API.
| print(sum_of_squares(100)) | |
| if __name__ == "__main__": | |
| print(sum_of_squares(100)) |
| grades =[80, 70, 90] | ||
| min_grade_passing = 75 | ||
|
|
||
| total = 0 | ||
| for num in grades: | ||
| total += num | ||
| average = total // len(grades) | ||
|
|
||
| if average < min_grade_passing: |
There was a problem hiding this comment.
The function parameters grades and min_pass are being overwritten with hardcoded values, making the function ignore its inputs. Remove these assignments and use the parameters directly.
| grades =[80, 70, 90] | |
| min_grade_passing = 75 | |
| total = 0 | |
| for num in grades: | |
| total += num | |
| average = total // len(grades) | |
| if average < min_grade_passing: | |
| total = 0 | |
| for num in grades: | |
| total += num | |
| average = total // len(grades) | |
| if average < min_pass: |
| total = 0 | ||
| for num in grades: | ||
| total += num | ||
| average = total // len(grades) |
There was a problem hiding this comment.
Using integer division (//) for calculating average will truncate decimal values. Use regular division (/) to get accurate averages for grade comparison.
| average = total // len(grades) | |
| average = total / len(grades) |
| grades =[80, 70, 90] | ||
| min_grade_passing = 75 | ||
|
|
||
| total = 0 | ||
| for num in grades: | ||
| total += num | ||
| average = total // len(grades) | ||
|
|
||
| if average < min_grade_passing: | ||
| print("Fail") | ||
| else: | ||
| print("Pass") |
There was a problem hiding this comment.
The function prints the result instead of returning it. Replace print() calls with return statements to match the documented return type of str. Also, the hardcoded variable min_grade_passing should be replaced with the min_pass parameter.
| grades =[80, 70, 90] | |
| min_grade_passing = 75 | |
| total = 0 | |
| for num in grades: | |
| total += num | |
| average = total // len(grades) | |
| if average < min_grade_passing: | |
| print("Fail") | |
| else: | |
| print("Pass") | |
| # grades =[80, 70, 90] # Removed hardcoded grades | |
| # min_grade_passing = 75 # Removed hardcoded min_grade_passing | |
| total = 0 | |
| for num in grades: | |
| total += num | |
| average = total // len(grades) | |
| if average < min_pass: | |
| return "Fail" | |
| else: | |
| return "Pass" |
| pass | ||
| even_numbers = [] | ||
|
|
||
| for i in range(1, n): |
There was a problem hiding this comment.
The range should be range(1, n + 1) to include n itself, as the docstring states 'from 1 to n' (inclusive).
| for i in range(1, n): | |
| for i in range(1, n + 1): |
| print(even_numbers(20)) | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Module-level print statement should be removed. This creates side effects when the module is imported and is not part of the function's API.
| print(even_numbers(20)) | |
| if __name__ == "__main__": | |
| print(even_numbers(20)) |
| pass | ||
| odd_numbers = [] | ||
|
|
||
| for i in range(1,n): |
There was a problem hiding this comment.
The range should be range(1, n + 1) to include n itself, as the docstring states 'from 1 to n' (inclusive).
| for i in range(1,n): | |
| for i in range(1, n + 1): |
| for i in range(1,n): | ||
| if i % 2 != 0: | ||
| odd_numbers.append(i) | ||
| return odd_numbers |
There was a problem hiding this comment.
The return statement is inside the loop, causing the function to return after finding the first odd number. Unindent this line to be at the same level as the for loop.
| return odd_numbers | |
| return odd_numbers |
| print(odd_numbers(20)) | ||
|
|
There was a problem hiding this comment.
Module-level print statement should be removed. This creates side effects when the module is imported and is not part of the function's API.
| print(odd_numbers(20)) |
No description provided.