LoslegenKostenlos loslegen

Choosing the right context in coding tasks

You are a professor maintaining a Python project for student records. Grades are stored in a dictionary, with helper functions to fetch a student and calculate their average. The existing functions are saved in students.py, a file the LLM can access and use:

def get_student(student_id):
  return {"name": "Alice", "grades": [88, 92, 95]}

def calculate_average(grades):
  return round(sum(grades) / len(grades), 2)

You want to use these helpers to implement an add_grade() function that adds a grade to a student’s record and returns the updated average.

Diese Übung ist Teil des Kurses

AI-Assisted Coding for Developers

Kurs anzeigen

Anleitung zur Übung

- Prompt the model to **implement the `add_grade()` function** using the **context** of `get_student()` and `calculate_average()`, and require the answer as **PEP 8–formatted Python code**.

Interaktive Übung

In dieser interaktiven Übung kannst du die Theorie in die Praxis umsetzen.

Übung starten