Project: Your first Python file

This project checks that your tools work together: your terminal, your editor and Python. It is also the first time you write a program in a real editor and run it from a terminal, as you will for every project. If a step below is unfamiliar, the linked page explains it.

Before you start, make sure you have done these. If not, each one links to the page that walks through it:

  1. Learned the basics of the terminal: What a terminal is and Find your way around the terminal.
  2. Installed a terminal on your own computer and made your python-projects folder (~/Projects/python-projects): Install your terminal.
  3. Installed Python with uv: Install Python with uv.
  4. Installed VS Code and opened your python-projects folder in it: Set up your editor.

Preview the program

Here is the program you will write. The box below is only a preview, so you can see how it behaves. Press Run and a box asks for your color. Running it here does not count as doing the project. The project is to get this program working on your own computer, in your own editor, as described below.

Do it on your computer

  1. In VS Code, create a new file named my_color.py in your python-projects folder.
  2. Copy the code from the box above into my_color.py. Replace Your Name with your name and the date with the current date.
  3. Save the file in VS Code (Ctrl+S on Windows, Cmd+S on Mac). The terminal runs the saved version, not what is on screen.
  4. Open your terminal and move into your python-projects folder: cd ~/Projects/python-projects.
  5. Check that the file arrived with ls. You should see my_color.py in the list.
  6. Run the program with python my_color.py. It asks for your favorite color. Type one and press Enter.

Your terminal should look something like this (your color will differ):

~/Projects/python-projects $ ls
my_color.py
~/Projects/python-projects $ python my_color.py
Please enter your favorite color: blue
Your favorite color is blue.

If you can do this, your editor and Python are working and you are ready for the rest of the course.