ChatGPT · Module 02 of 8

Coding

Get code that fits your project, find the real cause of a bug, and analyze data files in Chat or Codex.

3 lessons12 techniques

Code generation

Get functions from exact signatures and examples, code that follows your conventions, tests alongside it, and builds in reviewable pieces.

4 techniques →

Debugging

Paste the exact error, cut the bug down to the smallest failing code, ask for causes before fixes, and reset after two failed attempts.

4 techniques →

Data analysis

Upload a CSV, explain your columns, check the Python and row counts behind each answer, and turn a cleanup into a reusable script.

4 techniques →
Check yourself

How well do you code and analyze data with ChatGPT?

Six scenarios on writing code, handling data and fixing bugs. Answers show after each pick, and you won't need to create an account.

Take the quiz
ChatGPT for coding

Chat or Codex?

This is the choice that matters most for coding now. In a chat, ChatGPT can't see your repository, so it only knows what you paste and can't run your project. Codex can read your files and run commands inside a sandbox. OpenAI's plans give Free and Go Codex in the desktop app, subject to rollout, with the CLI and IDE extension starting at Plus. As a rule of thumb, use Chat for a single function or an explanation, and Codex once a task involves more than a couple of files or needs tests run.

Where the lessons fit

Code generation covers getting code that fits your project. Debugging covers what to do once something fails. Data analysis is a little different: ChatGPT itself writes and runs Python on files you upload, so you can work with real numbers without any setup. All three share one idea, which is to give ChatGPT something it can be checked against, such as a test, a reproduction or a total you already trust. Neither a tidy answer nor a confident tone is evidence that the code works.

Frequently asked
Can ChatGPT write code?

Yes. In Chat, it writes code from what you paste, and you run it yourself. Codex, OpenAI's coding agent, can read your repository, edit files and run commands in a sandbox. The CLI and IDE extension start at Plus, at $20 a month as checked on 6 November 2026.

Can ChatGPT run code?

Its data analysis feature writes and runs Python on files you upload, but a chat can't run your own project. For that, use Codex, which can run your tests and commands in a sandbox that, by default, limits writes to your workspace and keeps network access off.

What's the best ChatGPT model for coding?

OpenAI's notes suggest Sol at Medium effort for everyday and complex coding, and Luna at High for focused, repeatable tasks. GPT-6 Astra is for the hardest end-to-end work, and it uses your allowance much faster. Availability depends on your plan.

Is Codex included with ChatGPT Plus?

Yes. OpenAI lists Codex on web, CLI, IDE and iOS for Plus, with usage limits. Free and Go have GPT-6 Luna in the desktop app, subject to rollout. You can also use Codex with an API key at API rates.