Use this file to discover all available pages before exploring further.
During this lesson, you’ll notice Composer’s chat pane now offers three modes—Agent, Cursor Ask, and Edit—accessible via Command-L on Mac or Control-L on Windows/Linux. Although the labels have changed, all previous functionality remains intact. Let’s explore each mode and see how they streamline your development workflow.
In Files & Folders, search for grades.csv and add it as context.
Switch to Cursor Ask mode and enter:
Write a Python function to parse grades.csv containing student grades and calculate the average score for each student, using Pandas. Apply it to grades.py.
Composer will detect that grades.py is empty and suggest code. Click Apply to grades.py:
Composer inserts the following into grades.py:
import pandas as pddef calculate_student_averages(file_path: str) -> pd.DataFrame: """ Parse a CSV file containing student grades and calculate the average score for each student. Args: file_path (str): Path to the CSV file. Returns: pandas.DataFrame: DataFrame with student names and their average scores. """ df = pd.read_csv(file_path) df['average'] = df.iloc[:, 1:].mean(axis=1) return df[['student', 'average']]if __name__ == "__main__": result = calculate_student_averages('grades.csv') print(result)
Before running the script, install Pandas:
pip install pandas
Run the script:
python grades.py
You’ll see each student’s average score printed to the console.
You’re not limited to files in context. In a new chat, ask for any snippet:
Create a function to fetch current weather data from the OpenWeatherMap API for a given city.
Composer returns:
import requestsdef get_weather_data(city: str, api_key: str) -> dict: """ Fetch current weather data from OpenWeatherMap API for a given city. Args: city (str): Name of the city. api_key (str): Your OpenWeatherMap API key. Returns: dict: Weather data if successful, None otherwise. """ base_url = "https://api.openweathermap.org/data/2.5/weather" params = { "q": city, "appid": api_key, "units": "metric" } try: response = requests.get(base_url, params=params) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: print(f"Error fetching weather data: {e}") return None
You can then apply this snippet directly into any open file.