Skip to content
Open
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": null
},
{
"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
}
]
30 changes: 14 additions & 16 deletions task-1/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,17 @@


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().title()


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()


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.title() if cleaned else "Unknown"


def clean_salary(raw: str) -> int | None:
Expand All @@ -38,4 +28,12 @@ def clean_salary(raw: str) -> int | None:
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.upper() == "N/A":
Comment thread
mohammedalfakih-dev marked this conversation as resolved.
return None

try:
return int(cleaned)
except ValueError:
Comment thread
mohammedalfakih-dev marked this conversation as resolved.
return None

43 changes: 34 additions & 9 deletions task-2/AI_DEBUG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,46 @@ Document one debugging session you had during Task 1 where you used an LLM

## The Error

<!-- 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, my first version of `clean_salary` removed commas but did not safely handle invalid salary values.

## The Prompt

<!-- The exact text you sent to the LLM. Include the code you pasted with
it. -->
I'm cleaning salary values from a CSV.

The inputs can look like "85000", " 95000", '"68,000"', "N/A", or empty strings.
I want to return an int when possible, or None for missing/invalid values.

Is this function safe, or could it crash on certain inputs?

```python
def clean_salary(raw: str) -> int | None:
cleaned = raw.strip().replace(",", "")
if not cleaned or cleaned.upper() == "N/A":
return None
return int(cleaned)
```

## The Solution

<!-- What did the LLM suggest? Did it work on the first try, or did you
need a follow-up? -->
ChatGPT explained that my function could crash because int(cleaned) was not inside a try/except block. It also pointed out that I should remove quote characters as well as commas.

the suggested fix:

```python
def clean_salary(raw: str) -> int | None:
cleaned = raw.strip()

if not cleaned or cleaned.upper() == "N/A":
return None

cleaned = cleaned.replace('"', "").replace(",", "")

try:
return int(cleaned)
except ValueError:
return None
```

## 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? -->
understand why the original code was broken. The CSV values are strings, and not every salary string can safely be converted directly with int(). Values like "68,000", N/A, empty strings, or unexpected formats can cause problems. Next time, I would test my helper function with several messy examples before running the full script, especially when converting strings into numbers.
Binary file added task-3/avatar&email.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added task-3/rg-hyf-students-readonly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added task-3/the directory switcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.