Skip to content

--Hazel Sibhuku#11

Open
let-Hazel wants to merge 4 commits into
micanipho:mainfrom
let-Hazel:main
Open

--Hazel Sibhuku#11
let-Hazel wants to merge 4 commits into
micanipho:mainfrom
let-Hazel:main

Conversation

@let-Hazel
Copy link
Copy Markdown

No description provided.

@micanipho micanipho requested a review from Copilot October 27, 2025 14:39
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 solutions for a series of Python programming exercises covering functions, loops, and basic algorithms. The changes replace placeholder pass statements with working implementations for most functions, though several remain incomplete.

Key Changes:

  • Implemented basic mathematical functions (sum of squares, even/odd number generation)
  • Added loop-based data processing functions (filtering, transformations, aggregations)
  • Included test code with print statements for manual verification

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
student_code.py Implements multiple function solutions with test cases; adds section markers between questions
pract.py Contains scratch work and experimental code for some of the exercises

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread student_code.py
Comment on lines +22 to +27
for i in grades:
if ave >= min_pass:
return "Pass"
else:
return "Fail"
return
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The loop iterates over grades but the condition checks 'ave >= min_pass' which is independent of 'i'. The function will always return on the first iteration, making the loop unnecessary. The logic should check the average once outside the loop.

Suggested change
for i in grades:
if ave >= min_pass:
return "Pass"
else:
return "Fail"
return
if ave >= min_pass:
return "Pass"
else:
return "Fail"

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
return "Pass"
else:
return "Fail"
return
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

This unreachable return statement will never execute since the function always returns in the loop above. This line should be removed.

Suggested change
return

Copilot uses AI. Check for mistakes.
Comment thread student_code.py

return list

print(skip_num(2, 10))
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

This line calls 'skip_num' but should call 'break_test' based on the function context. The incorrect function is being tested here.

Suggested change
print(skip_num(2, 10))
print(break_test(2, 10))

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Parameters:
nums (list): A list of integers.
for i in nums:
if i >= 0:
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The condition checks for non-negative numbers (>= 0) but the function name is 'count_positive_numbers'. Zero is not a positive number. The condition should be 'i > 0'.

Suggested change
if i >= 0:
if i > 0:

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +346 to +350
for i in nums:
if i%2==0:
pass #do something
else:
return sum(nums)/len(nums)
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The logic for finding the median is incorrect. This implementation returns the mean (average) on the first odd number, which is not how median is calculated. The median requires sorting the list and finding the middle value(s).

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
def reverse_string(input: str):
"""
Reverse the given string.
string = input
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The variable 'string' is assigned but never used. This line should be removed as it serves no purpose.

Suggested change
string = input

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +374 to +375
for i in nums:
i = max(nums)
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The loop unnecessarily iterates through all numbers and repeatedly calculates max(nums). The max value should be computed once outside the loop: 'return max(nums)' or handle empty list appropriately.

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +387 to +390
if n%2 != 0:
return True
else:
return False
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The prime number check is incorrect. This only checks if a number is odd, but not all odd numbers are prime (e.g., 9, 15, 21). A proper prime check requires testing divisibility by all numbers from 2 to sqrt(n).

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