Python in Excel and AI: practice exercises
Excel now runs Python and AI assistants, and these exercises show where each helps. You read short pandas snippets and reproduce their results with formulas, learn when to reach for the PY function, try Copilot prompts for formulas and analysis, and learn how to check an AI answer before using it. Every task is small and verifiable, which matters most when a tool can sound confident and still be wrong. A modern complement to the classic formula exercises.
17 exercises · level: Expert
Start with the first task Study the course: Python in Excel and AI →
Showing 17 of 17
pandas and Python Charts
In D2:D9, clean up the city names: no extra spaces and a capital first letter (like str.strip().str.title()).
In E2:E9, turn the text amounts into numbers (like pd.to_numeric). Leave empty ones empty.
In H1, count how many rows remain after dropna: how many real numbers are in E2:E9.
In H2, find the sum, and in H3 the average of the cleaned column E.
In F2:F4, repeat df.groupby("City")["Amount"].sum().
In G2:G4, calculate count: the number of sales in each city.
In H2:H4, calculate mean: the average sale per city.
Check: in F5 add up the group totals, and in F6 the overall total of column C. The numbers must match.
In F8, repeat grouping by two keys: the sales total for Emma in Austin.
AI Assistants
In F2, calculate the correct average deal: Austin only.
In F3, recalculate Boston's revenue with your own formula.
In F5, compare your result with the AI answer: "Correct" if they match, otherwise "AI error".
In F8, calculate Boston's revenue with tax. Take the rate from F7 instead of typing a number.
In F2:F7, replace names with codes C001, C002… based on the row number.
In G2:G7, mask the phone numbers: "***" followed by the last 4 digits.
In J2:J4, build the aggregate to hand to the AI: the total for each city, with no names.
In J5, check that the aggregate didn't lose any money: "OK" if the sum of J2:J4 equals the sum of D2:D7, otherwise "Error".
No exercises match these filters.