Assign Student Grades from CSV Marks
Updated
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 CSV has already been loaded into the students dataframe, using the schema shown. Implement assign_grades(students) to give every row a letter grade. Loading the CSV is only background. Your job is to add the grade column to the dataframe you are given.
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.
More Hartford Financial Services interview questions
Similar questions at other companies
- Nested Transaction Key-Value Store with Value CountsLyft · ONSITE INTERVIEWLyft interview questions
- Track the Book and Mark Final PnLMillennium · OAMillennium interview questions
- Parquet-Like Columnar Format OperationsJump Trading · PHONE SCREENJump Trading interview questions
- In-Memory Database Historical LookupAnthropic · OAAnthropic interview questions
- Process Airline Seat RequestsAgoda · OAAgoda interview questions
- Christmas Tree with N TiersVerily · ONSITE INTERVIEW
- Delete Duplicate Employee RecordsInfosys · ONSITE INTERVIEWInfosys interview questions
- Ring Buffer OperationsAmazon · ONSITE INTERVIEW
- Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Records Created or Updated in a Time WindowPelatro · ONSITE INTERVIEW