Skip to content

I tried really#12

Open
AshlyVuba wants to merge 3 commits into
micanipho:mainfrom
AshlyVuba:main
Open

I tried really#12
AshlyVuba wants to merge 3 commits into
micanipho:mainfrom
AshlyVuba:main

Conversation

@AshlyVuba
Copy link
Copy Markdown

No description provided.

@micanipho micanipho requested a review from Copilot October 27, 2025 14:40
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 student exercise functions that were previously stubbed with pass statements. The changes include implementations for mathematical operations, list manipulations, string processing, and statistical calculations.

Key changes:

  • Implementation of 20+ functions including sum calculations, list filtering, performance evaluation, and string manipulation
  • Addition of math and statistics module imports
  • Inclusion of VS Code testing configuration for unittest framework

Reviewed Changes

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

File Description
student_code.py Implements all previously stubbed functions with working logic for calculations, filtering, and data processing
.vscode/settings.json Adds unittest configuration for Python testing in VS Code

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

Comment thread student_code.py
Comment on lines +34 to +39
dict = {}
for i in grades:
if i >= min_pass:
return f"{i} Pass"
else:
return f"{i} Fail"
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 function returns immediately on the first grade instead of calculating the average of all grades as specified in the docstring. The function should compute the average of all grades and compare it to min_pass.

Suggested change
dict = {}
for i in grades:
if i >= min_pass:
return f"{i} Pass"
else:
return f"{i} Fail"
if not grades:
return "Fail"
average = sum(grades) / len(grades)
if average >= min_pass:
return "Pass"
else:
return "Fail"

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +52 to +55
lis = []
for i in scores.values():
lis.append(i)
return sum(lis)/len(lis)
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 return statement is inside the loop, causing the function to return after processing only the first value. Move the return statement outside the loop. Additionally, the function should return a dictionary with average and below-average subjects according to the docstring, not just a number.

Suggested change
lis = []
for i in scores.values():
lis.append(i)
return sum(lis)/len(lis)
if not scores:
return {"average": 0, "below_average_subjects": []}
average = sum(scores.values()) / len(scores)
below_average_subjects = [subject for subject, score in scores.items() if score < average]
return {"average": average, "below_average_subjects": below_average_subjects}

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +69 to +82
dictionary = {}
positve = False
negative = False
neutral = False
for i in scores:
if i > 0:
positve = True
return positve
elif i < 0:
negative = True
return negative
elif i == 0:
neutral = True
return neutral
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 function returns on the first score instead of analyzing the trend across all scores. The function should determine the overall trend based on all values in the list and return a dictionary with 'trend' and 'improvement' keys as specified in the docstring.

Suggested change
dictionary = {}
positve = False
negative = False
neutral = False
for i in scores:
if i > 0:
positve = True
return positve
elif i < 0:
negative = True
return negative
elif i == 0:
neutral = True
return neutral
if not scores or len(scores) == 1:
# Not enough data to determine trend
return {'trend': 'neutral', 'improvement': False}
increases = 0
decreases = 0
for prev, curr in zip(scores, scores[1:]):
if curr > prev:
increases += 1
elif curr < prev:
decreases += 1
if increases > decreases:
trend = 'positive'
improvement = True
elif decreases > increases:
trend = 'negative'
improvement = False
else:
trend = 'neutral'
improvement = False
return {'trend': trend, 'improvement': improvement}

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
lis = []
for i in range(1,length+1):
if i != n:
print(lis.append(i))
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 print statement wraps lis.append(i) which returns None. Remove the print wrapper and just use lis.append(i).

Suggested change
print(lis.append(i))
lis.append(i)

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +178 to +180
for i in range(1,length):
if i <= n:
print(lis.append(i))
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 print statement wraps lis.append(i) which returns None. Remove the print wrapper. Additionally, the logic should break when encountering n (not <=), and it should be if i < n or use a break statement when i == n.

Suggested change
for i in range(1,length):
if i <= n:
print(lis.append(i))
for i in range(1, length):
if i == n:
break
lis.append(i)

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
for num in nums:
if num % 2 == 0:
even.append(num)
print(even)
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 function prints the list but doesn't return it. According to the docstring, the function should return a list. Change print(even) to return even.

Suggested change
print(even)
return even

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

median = statistics.median(nums)
print(median)
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 function prints the median but doesn't return it. According to the docstring, the function should return a float or int. Change print(median) to return median.

Suggested change
print(median)
return median

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
Comment on lines +380 to +383
largest = max(nums)
if not nums:
return None#stuck here
print(largest)
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 empty list check happens after calling max(nums), which will raise a ValueError on an empty list. Move the if not nums check to the beginning of the function before calling max(). Also, change print(largest) to return largest.

Suggested change
largest = max(nums)
if not nums:
return None#stuck here
print(largest)
if not nums:
return None
largest = max(nums)
return largest

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
if n < 2:
return False
if n == 2:
return True
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 function doesn't check if n is even before starting the loop at 3 with step 2. Add a check if n % 2 == 0: return False after the n == 2 check to handle even numbers correctly.

Suggested change
return True
return True
if n % 2 == 0:
return False

Copilot uses AI. Check for mistakes.
Comment thread student_code.py
for word in word_sentence.lower():
if word == char_count:
count += 1
return print(count)
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 expression return print(count) returns None since print() returns None. Change this to return count to return the integer count as specified in the docstring.

Suggested change
return print(count)
return count

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