Skip to main content

Homework 7 — Student Demographics: Structured Data

Skills: 11, 12

Due

Thursday, October 23, 2025 at 6PM (Oakland) or 9PM (Boston)

Submission

This HW, like all homeworks, is done on https://github.com and submitted on https://app.pawtograder.com. Go to Pawtograder to find the repository where the assignment should be done. Commits automatically make submissions, and feedback can be viewed on Pawtograder.


Introduction

You're working for a university's enrollment system to track student diversity and academic information. The university wants to better understand their student body demographics. You'll be designing data structures and functions to represent and analyze student information. Throughout this assignment, you'll work with structured data definitions to represent student demographics and academic records.

Problem 1

Design a data definition called StudentRecord that represents a student with the following information:

  • Student name (String)
  • Age (Number)
  • Major (String)
  • GPA (Number)

Write several examples, as constant definitions, of your StudentRecord.

Problem 2

Write a function generate-report that takes a StudentRecord and produces a comprehensive String report. It should produce a string of the form:

=== STUDENT REPORT ===\nName: <Student name>\nAge: <Age> years old\nMajor: <Major>\nGPA: <GPA>

NOTE: We have you place "newline characters" ("\n") between each "line" of the report. These are special characters in strings that are used to communicate the idea of breaking a line. A function that prints out strings, converting special characters like newlines into what they represent in the print() function.

Note that print() also returns your string, so you will see two copies -- first the output that is printed (where the newline characters turn into line breaks), and then the original string (where you can see the newline characters). If you only want to see what print() is displaying and don't also want to see the return value, you can always store it in a name you aren't using, i.e., run something like IGNORE = print(generate-report(...)) at the interactions.

Problem 3

Create a new data definition StudentProfile that combines a StudentRecord with a String that represents three possible options about demographics: "international", "domestic", and "didnotshare". This represents complete information about a student.

Write several examples, as constant definitions, of your StudentProfile.

Problem 4

Design a function count-international that takes a list of StudentProfiles and returns the number of international students.

Problem 5

Design a function high-achievers takes a list of StudentProfiles and returns a list containing only students with GPA above 3.7.

Problem 5a.

You’ve noticed that the average cumulative GPAs of students in some majors consistently differ from the average cumulative GPAs of students in other majors. You wonder whether using the same GPA cutoff for determining “high-achieving” students is facially neutral but also misleading.

“Facially neutral” means something that is neutral “on its face” or “at first glance”, but perhaps unfairly biased when seen in its fuller context. For an example, consider the writer Anatole France’s sardonic observation that it’s illegal for everyone – no matter how destitute or how wealthy – to sleep under bridges, beg on the streets, or steal bread. The laws forbidding those things are facially neutral: on their face, they apply to everyone. In a fuller context, such laws seem to compound the struggles faced by destitute people, not by wealthy people.

Question: Should the cutoff cumulative GPA for “high achievers” be defined: (a) in relation to the students’ major(s), (b) regardless of a student’s major, or (c) in some other way? Explain your answer in two or three sentences.