diff --git a/task-1/output/clean_users.json b/task-1/output/clean_users.json new file mode 100644 index 0000000..5c6a75c --- /dev/null +++ b/task-1/output/clean_users.json @@ -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 + } +] \ No newline at end of file diff --git a/task-1/src/__pycache__/utils.cpython-311.pyc b/task-1/src/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000..cacd14d Binary files /dev/null and b/task-1/src/__pycache__/utils.cpython-311.pyc differ diff --git a/task-1/src/utils.py b/task-1/src/utils.py index 2762398..06f6851 100644 --- a/task-1/src/utils.py +++ b/task-1/src/utils.py @@ -5,7 +5,10 @@ keep them pure so they are easy to test. """ + + from __future__ import annotations +#from curses import raw def clean_name(raw: str) -> str: @@ -13,7 +16,10 @@ def clean_name(raw: str) -> str: 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: @@ -21,7 +27,13 @@ def clean_email(raw: str) -> str: 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: @@ -29,13 +41,27 @@ def clean_department(raw: str) -> str: 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)) + except (ValueError, TypeError): + return None + + #raise NotImplementedError("Implement clean_salary (Task 1)") diff --git a/task-2/AI_DEBUG.md b/task-2/AI_DEBUG.md index 413b94a..ca38dd2 100644 --- a/task-2/AI_DEBUG.md +++ b/task-2/AI_DEBUG.md @@ -12,18 +12,49 @@ Document one debugging session you had during Task 1 where you used an LLM +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 +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 +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 + +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. diff --git a/task-3/azure_proof.png b/task-3/azure_proof.png new file mode 100644 index 0000000..6082dd2 Binary files /dev/null and b/task-3/azure_proof.png differ