Skip to content
Open

Muna #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions task-1/output/clean_users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"id": 1,
"name": "Alice Johnson",
"email": "alice.johnson@company.com",
"department": "Engineering",
"salary": 85000
},
{
"id": 2,
"name": "Bob Smith",
"email": "bob.smith@company.com",
"department": "Unknown",
"salary": 72000
},
{
"id": 3,
"name": "Carol Williams",
"email": "carol.williams@company.com",
"department": "Engineering",
"salary": null
},
{
"id": 4,
"name": "David, Jr.",
"email": "david.brown@company.com",
"department": "Sales",
"salary": 68000
},
{
"id": 5,
"name": "Caf\u00e9 Owner",
"email": "eva@company.com",
"department": "Engineering",
"salary": 88000
},
{
"id": 6,
"name": "FRANK WILSON",
"email": "frank@company.com",
"department": "marketing",
"salary": 95000
},
{
"id": 7,
"name": "Grace Lee",
"email": "grace.lee@company.com",
"department": "Engineering",
"salary": null
},
{
"id": 9,
"name": "Henry Davis",
"email": "henry.davis@company.com",
"department": "Sales",
"salary": 82000
},
{
"id": 11,
"name": "Linda Taylor",
"email": "linda.t@company.com",
"department": "HR",
"salary": 55000
},
{
"id": 12,
"name": "Mike Brown",
"email": "mike.b@company.com",
"department": "Sales",
"salary": 62
},
{
"id": 13,
"name": "Sarah Connor",
"email": "s.connor@sky.net",
"department": "Unknown",
"salary": -1
},
{
"id": 15,
"name": "John Doe",
"email": "john.doe@company.net",
"department": "Engineering",
"salary": 100000
}
]
Binary file added task-1/src/__pycache__/utils.cpython-311.pyc
Binary file not shown.
34 changes: 30 additions & 4 deletions task-1/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,63 @@
keep them pure so they are easy to test.
"""



from __future__ import annotations
#from curses import raw


def clean_name(raw: str) -> str:
"""Strip leading/trailing whitespace from a name.

Returns the cleaned string. An empty input returns "".
"""
raise NotImplementedError("Implement clean_name (Task 1)")
return raw.strip()


#raise NotImplementedError("Implement clean_name (Task 1)")


def clean_email(raw: str) -> str:
"""Lowercase the email, strip surrounding whitespace.

Returns the cleaned string. An empty input returns "".
"""
raise NotImplementedError("Implement clean_email (Task 1)")
return raw.strip().lower()





#raise NotImplementedError("Implement clean_email (Task 1)")


def clean_department(raw: str) -> str:
"""Return the department, or 'Unknown' if missing/empty.

Strip whitespace; treat empty string as missing.
"""
raise NotImplementedError("Implement clean_department (Task 1)")
cleaned = raw.strip()
return cleaned if cleaned else "Unknown"

#raise NotImplementedError("Implement clean_department (Task 1)")


def clean_salary(raw: str) -> int | None:

"""Parse a messy salary cell into an int.

Handles inputs like "85000", " 95000", '"68,000"', "N/A", "".
Returns None when the value cannot be parsed (missing or "N/A").
"""
raise NotImplementedError("Implement clean_salary (Task 1)")
cleaned = raw.strip().replace(",", "").replace('"', "")

if not cleaned or cleaned.lower() == "n/a":
return None

try:
return int(float(cleaned))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This would truncate decimals as well, would be better if you return None for this case, and add a log to specify that that we're explicitly rejecting decimals for this case, just keep it as int(cleaned)

except (ValueError, TypeError):
return None

#raise NotImplementedError("Implement clean_salary (Task 1)")
31 changes: 31 additions & 0 deletions task-2/AI_DEBUG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,49 @@ Document one debugging session you had during Task 1 where you used an LLM
<!-- Paste the full traceback or describe the wrong behaviour. Include the
exact error message and the line of your code that triggered it. -->

During Task 1, I encountered two main issues. First, an accidental import was added:
`from curses import raw`
This caused potential environment errors. Second, the `clean_salary` function did not return a value in all cases.
If the input was not a digit, the function would exit without returning anything, which caused unexpected behavior.

## The Prompt

<!-- The exact text you sent to the LLM. Include the code you pasted with
it. -->

I asked ChatGPT:

"My function clean_salary sometimes doesn't return a value. Here is my code:

def clean_salary(raw: str) -> int | None:
cleaned = raw.strip().replace(',', '')
if cleaned.isdigit():
return int(cleaned)

Why is it failing and how can I fix it?"

## The Solution

<!-- What did the LLM suggest? Did it work on the first try, or did you
need a follow-up? -->

The AI explained that my function was missing a return statement for cases where the input is not a valid number.

It suggested adding:

return None

at the end of the function.

After adding this line, the function worked correctly on all test cases.

## Reflection

<!-- A few sentences on: did you understand WHY the original code was
broken, or did you just accept the fix? What would you do differently next
time? -->

I understood that the problem was caused by missing return paths in my function.
At first, I just followed the AI suggestion, but then I realized that in Python every condition must return a value or the function will return None implicitly.

Next time, I will first check all possible input cases myself before asking AI for help.
Binary file added task-3/azure_proof.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.