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
47 changes: 47 additions & 0 deletions clean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

raw_student_records = [
{"id": "101", "name": "vijay", "marks": "85.5", "skills": ["Python", "Git", "Python"]},
{"id": "102", "name": "ANITA", "marks": "92", "skills": ["Java", "SQL"]},
{"id": "101", "name": "Vijay", "marks": "85.5", "skills": ["Python", "Git"]},
{"id": "103", "name": "rahul", "marks": "78.0", "skills": ["Git", "C++", "Git"]},
]

def clean_records(raw_data):
"""
Cleans raw student records:
1. Removes duplicate IDs (keeps last occurrence)
2. Converts id → int
3. Normalizes name → Proper Case
4. Converts marks → float
5. Removes duplicate skills using set()
Returns a dict keyed by integer student ID.
"""

# ── 1. Remove duplicate entries (keep last occurrence per ID) ────────────
unique = {}
for record in raw_data:
unique[record["id"]] = record # same ID? newer record wins

# ── 2. Clean each field ──────────────────────────────────────────────────
cleaned = {}
for sid, record in unique.items():
clean_id = int(sid) # "101" → 101
clean_name = record["name"].strip().capitalize() # "vijay" → "Vijay"
clean_marks = float(record["marks"]) # "85.5" → 85.5
clean_skills = set(record["skills"]) # removes duplicates

cleaned[clean_id] = {
"name" : clean_name,
"marks" : clean_marks,
"skills": clean_skills,
}

return cleaned


# ── Run standalone test (Member A can verify their own work) ─────────────────
if __name__ == "__main__":
result = clean_records(raw_student_records)
print("=== [Member A] Cleaned Data Preview ===")
for sid, info in sorted(result.items()):
print(f" ID {sid}: {info}")
74 changes: 74 additions & 0 deletions evaluator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# ============================================================
# FILE : data_evaluation.py
# OWNER : Team Member B
# TASK : Evaluate the cleaned student records
# HOW : Member B downloads data_cleaning.py from the shared
# folder (Google Drive / OneDrive) and keeps BOTH
# files in the SAME folder, then runs this file.
# ============================================================

# ── Member B imports Member A's cleaned data ─────────────────────────────────
from clean import clean_records, raw_student_records

def evaluate_records(cleaned_data):
"""
Evaluates cleaned student records:
1. Determines Pass / Fail (marks >= 40 → Pass)
2. Adds 'pass' key to each record
3. Prints a full summary report
Returns the final evaluated dictionary.
"""

evaluated = {}

for sid, info in cleaned_data.items():
is_pass = info["marks"] >= 40.0 # evaluation logic

evaluated[sid] = {
"name" : info["name"],
"marks" : info["marks"],
"skill" : info["skills"], # rename to match expected output
"pass" : is_pass,
}

return evaluated


def print_report(evaluated_data):
"""Prints a formatted summary report."""
print("=" * 55)
print(" Final Evaluated Student Records Report")
print("=" * 55)

total = len(evaluated_data)
passed = sum(1 for s in evaluated_data.values() if s["pass"])
failed = total - passed

for sid, info in sorted(evaluated_data.items()):
status = "✅ PASS" if info["pass"] else "❌ FAIL"
print(f"\n Student ID : {sid}")
print(f" Name : {info['name']}")
print(f" Marks : {info['marks']}")
print(f" Skills : {info['skill']}")
print(f" Result : {status}")

print("\n" + "─" * 55)
print(f" Total Students : {total}")
print(f" Passed : {passed}")
print(f" Failed : {failed}")
print("=" * 55)

print("\nFinal Dictionary (exact expected output):")
print(evaluated_data)


# ── Main execution ────────────────────────────────────────────────────────────
if __name__ == "__main__":
# Step 1: Get cleaned data from Member A's file
cleaned = clean_records(raw_student_records)

# Step 2: Evaluate (Member B's job)
final = evaluate_records(cleaned)

# Step 3: Print the report
print_report(final)
36 changes: 36 additions & 0 deletions student_records.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
raw_student_records = [
{"id": "101", "name": "vijay", "marks": "85.5", "skills": ["Python", "Git", "Python"]},
{"id": "102", "name": "ANITA", "marks": "92", "skills": ["Java", "SQL"]},
{"id": "101", "name": "Vijay", "marks": "85.5", "skills": ["Python", "Git"]},
{"id": "103", "name": "rahul", "marks": "78.0", "skills": ["Git", "C++", "Git"]},
]

# ---------------------------------------------------------------------------
# Transform raw_student_records into the required clean dictionary
# ---------------------------------------------------------------------------
cleaned_students = {}

for record in raw_student_records:
student_id = int(record["id"]) # str → int
name = record["name"].title() # any case → Title Case
marks = float(record["marks"]) # str → float
skills = set(record["skills"]) # list (with duplicates) → set
passed = marks >= 40 # pass/fail rule

if student_id not in cleaned_students:
# First time we see this id – store it
cleaned_students[student_id] = {
"name" : name,
"marks" : marks,
"skill" : skills,
"pass" : passed,
}
else:
# Duplicate id – merge skills (union) and keep the rest as-is
cleaned_students[student_id]["skill"] |= skills

# ---------------------------------------------------------------------------
# Display result
# ---------------------------------------------------------------------------
for sid, info in cleaned_students.items():
print(f"{sid}: {info}")