Assign Student Grades from CSV Marks
Problem statement
You receive student marks from a comma-separated CSV with header student_id,marks. Each record has one unique student ID and one integer mark.
The practice runner has already parsed that CSV into the students dataframe using the displayed schema. Implement assign_grades(students) to assign a letter grade to every row. CSV loading is context for this exercise; the judged operation is the column transformation on the supplied dataframe.
Use these grade bands:
| Mark | Grade |
|---|---|
90..100 | A |
80..89 | B |
70..79 | C |
60..69 | D |
0..59 | F |
Return a dataframe with columns student_id, marks, and grade in that order. Retain every original ID and mark and preserve the CSV row order. Equal marks still belong to separate students. Do not average marks, sort or group students, or round marks.
A header-only CSV is valid and returns an empty dataframe with the same three result columns.
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
students
Records parsed from CSV columns student_id,marks in their original row order.
| Column | Type | Nullable | Description |
|---|---|---|---|
| student_idPK | Integer | No | Unique student identifier; preserves the identity of each CSV row. |
| marks | Integer | No | One mark per student, from 0 through 100 inclusive. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| student_id | Integer | No | Unique student identifier; preserves the identity of each CSV row. |
| marks | Integer | No | One mark per student, from 0 through 100 inclusive. |
| grade | Text | No | A, B, C, D or F assigned by the displayed integer mark bands. |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- The CSV has header
student_id,marksand from0through1000data rows. - Student IDs are unique integers from
1through10^9. - Every mark is an integer from
0through100; neither field is null. - Each record already contains the single mark used for its grade; no subject aggregation or rounding is required.