Skip to content

Ntsika Test Done#3

Open
DyanCoded wants to merge 2 commits into
micanipho:mainfrom
DyanCoded:main
Open

Ntsika Test Done#3
DyanCoded wants to merge 2 commits into
micanipho:mainfrom
DyanCoded:main

Conversation

@DyanCoded
Copy link
Copy Markdown

No description provided.

@FreakyJay1 FreakyJay1 requested a review from Copilot October 21, 2025 12:07
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 implements multiple Python functions for learning outcomes related to functions, loops, data processing, and simple algorithms. The changes replace placeholder pass statements with working implementations across various utility functions.

Key changes:

  • Implementation of mathematical functions (sum_of_squares, sum_multiples_of_num)
  • Implementation of list filtering and processing functions (even_numbers, odd_numbers, filter_even_numbers)
  • Implementation of algorithm functions (largest_number, is_prime, reverse_string)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread student_code.py
Comment on lines +11 to +14
for _ in range(1, n + 1):
sum = n * n
total += sum
return sum
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The loop variable is unused and the calculation is incorrect. Line 12 should use the loop variable (e.g., i) instead of n, and should calculate i * i. Currently, this adds n * n a total of n times, producing n^3 instead of the sum of squares.

Suggested change
for _ in range(1, n + 1):
sum = n * n
total += sum
return sum
for i in range(1, n + 1):
total += i * i
return total

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
for _ in range(1, n + 1):
sum = n * n
total += sum
return sum
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Returns the wrong variable. Should return total instead of sum to provide the accumulated sum of squares.

Suggested change
return sum
return total

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +7 to +16
try:
if n == 0:
return n
elif n > 0:
for _ in range(1, n + 1):
sum = n * n
total += sum
return sum
except:
raise ValueError
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Bare except clause catches all exceptions including system exits. Should specify the expected exception type (e.g., except TypeError:) or remove the try-except block entirely since no exception-raising code is present in the try block.

Suggested change
try:
if n == 0:
return n
elif n > 0:
for _ in range(1, n + 1):
sum = n * n
total += sum
return sum
except:
raise ValueError
if n == 0:
return n
elif n > 0:
for _ in range(1, n + 1):
sum = n * n
total += sum
return sum

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +28 to +29
for _ in range(len(grades)):
num_of_grades += 1
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Unnecessary loop to count list elements. Replace with num_of_grades = len(grades) for clearer and more efficient code.

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
pass
count = 0

for i in count_positive_numbers_nums:
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Uses global variable count_positive_numbers_nums instead of the function parameter nums. Should iterate over nums parameter instead.

Suggested change
for i in count_positive_numbers_nums:
for i in nums:

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
pass
even_nums = []

for i in filtering_nums:
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Uses global variable filtering_nums instead of the function parameter nums. Should iterate over nums parameter instead.

Suggested change
for i in filtering_nums:
for i in nums:

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +448 to +453
largest_num = 0

for i in largest_number_nums:
if i > largest_num:
largest_num = i
# print(largest_num)
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Initialization to 0 fails for lists containing only negative numbers. Should initialize to nums[0] or float('-inf') to handle all cases correctly, or return None for empty lists as per docstring.

Suggested change
largest_num = 0
for i in largest_number_nums:
if i > largest_num:
largest_num = i
# print(largest_num)
if not nums:
return None
largest_num = nums[0]
for i in nums:
if i > largest_num:
largest_num = i

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
pass
largest_num = 0

for i in largest_number_nums:
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Uses global variable largest_number_nums instead of the function parameter nums. Should iterate over nums parameter instead.

Suggested change
for i in largest_number_nums:
for i in nums:

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +471 to +475
if i % n == 0:
return False
else:
return True

Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Logic is inverted. The condition checks if i is divisible by n, but should check if n is divisible by i (i.e., if n % i == 0:). This makes the function always return True for n > 2.

Suggested change
if i % n == 0:
return False
else:
return True
if n % i == 0:
return False
return True

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +470 to +475
for i in range(2, n):
if i % n == 0:
return False
else:
return True

Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Returns immediately after checking only the first divisor (2). The function should continue checking all divisors and only return True after the loop completes without finding any divisors.

Suggested change
for i in range(2, n):
if i % n == 0:
return False
else:
return True
if n < 2:
return False
for i in range(2, n):
if n % i == 0:
return False
return True

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