FastPrepAssign Student Grades from CSV Marks

Assign Student Grades from CSV Marks

Hartford Financial Services logoHartford Financial Services● EasyFULLTIMEONSITE INTERVIEW

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:

MarkGrade
90..100A
80..89B
70..79C
60..69D
0..59F

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

Pandas

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.

ColumnTypeNullableDescription
student_idPKIntegerNoUnique student identifier; preserves the identity of each CSV row.
marksIntegerNoOne mark per student, from 0 through 100 inclusive.

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
student_idIntegerNoUnique student identifier; preserves the identity of each CSV row.
marksIntegerNoOne mark per student, from 0 through 100 inclusive.
gradeTextNoA, 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,marks and from 0 through 1000 data rows.
  • Student IDs are unique integers from 1 through 10^9.
  • Every mark is an integer from 0 through 100; 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 problems

See Hartford Financial Services hiring insights