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.
Este ejercicio forma parte del curso
AI-Assisted Coding for Developers
Instrucciones del ejercicio
- 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**.
Ejercicio interactivo práctico
Pon en práctica la teoría con uno de nuestros ejercicios interactivos
 Empezar ejercicio
Empezar ejercicio