Quickstart on Python Programming with ChatGPT

Up to Topics: Python, ChatGPT

For learning any programming language, there are two parts, 1) general programming concepts, and 2) learning the syntax and conventions of the particular language.

We had a question in today's AI Salon event about the second part, for Python.

I was suggesting that asking ChatGPT is a good way to start, and I thought I'd explain a little more here. (I'll keep returning back to different parts of learning how to program, including general concepts, but I'll just dive in here now!)

I would start with some file manipulation task, like reading a text file, doing some transformation, and writing the output. Here's a good ChatGP prompt to start with:

Write a python script to (your task here) . Use argparse, and use -i to specify the input file, and optionally, -o to specify an output file. Use a shebang line, a main() function, and add logging for errors and information messages.

"your task" might be "convert a Markdown file to HTML". Ask ChatGPT for some other ideas of what task might be a good one to start with!

If you want to start with something which is a little advanced, you can watch me write a Flask API server (and a GPT to talk to it) in this AI 101 recording: Let's Build an API and a GPT, 2023-12-05.


Pages that link to this page