ChatGPT · Module 02 of 8

Coding

Generate, debug, and ship code with ChatGPT — from snippets to full features.

3 lessons12 exercises
Topics & techniques

Code generation

Turn requirements into working code.

4 cards →

Debugging

Diagnose and fix errors instead of guessing.

4 cards →

Data analysis

Use the code interpreter to analyse files and data.

4 cards →
ChatGPT for coding

Treat ChatGPT as a pair, not an oracle

ChatGPT writes competent code across most languages, but the developers who get real value treat it like a fast pair-programmer that needs a precise brief, not a vending machine. Give it the signature, the types, the surrounding code, and the constraint — 'this runs in a Lambda with a 3-second timeout' — and it produces code that fits your system. Ask it vaguely and you get plausible code that ignores your architecture. For anything with real logic, switch to a reasoning model so it thinks the problem through before writing.

Debugging: paste the error, not the vibe

The single biggest upgrade to debugging with ChatGPT is boring: paste the exact error message and the smallest snippet that reproduces it, rather than describing the symptom in prose. 'It doesn't work' forces guessing; a stack trace plus the failing function gives ChatGPT something concrete to reason from. For data work, its code interpreter can actually run Python on files you upload — so it can analyse, calculate, and chart rather than just suggest.

The coding topics worth drilling into

This section breaks down into code generation (turning requirements into working code), debugging (diagnosing real errors instead of guessing), and data analysis (using the code interpreter on your own files). Each card below is a specific, tested habit — start with whichever matches the problem in front of you right now.

Frequently asked
Can ChatGPT write code?

Yes, across most popular languages. It is strongest when you give it the types, the surrounding code, and the constraints rather than a one-line description. For logic-heavy tasks, use a reasoning model so it works through the problem before generating.

Can ChatGPT actually run code?

Yes — its data-analysis tool (code interpreter) executes Python in a sandbox, so it can process files you upload, run calculations, and produce charts. For pure code generation it writes the code for you to run in your own environment.

How do I get better bug fixes from ChatGPT?

Paste the exact error message and the smallest snippet that reproduces the bug instead of describing it. Concrete inputs let ChatGPT reason about the real cause rather than guessing at a plausible one. The debugging cards below show the full pattern.

Which ChatGPT model is best for coding?

Use the fast default for quick edits and boilerplate, and switch to a reasoning model for algorithms, tricky logic, or debugging where correctness matters more than speed. Matching the model to the task is especially valuable in coding.

Test yourself

How well do you code with ChatGPT?

Six questions on generating code that fits your project, debugging without guessing, and analysing data you can actually trust. No sign-up, instant score, and you can share how you did.

  1. Q1 Before asking ChatGPT for code, what should you state up front?
  2. Q2 What's the most reliable way to specify a function you want written?
  3. Q3 You're building a feature. What scope should each prompt have?
  4. Q4 You've hit a bug. What do you give ChatGPT?
  5. Q5 ChatGPT keeps cycling through variations of the same wrong fix. What now?
  6. Q6 The code interpreter returns a clean chart. What should you always ask for too?
0 / 6 answered