Python Basics for Vibe Coders

Python Basics for Vibe Coders, Part 1: Where Do You Run the Code AI Gives You?

Run Python for the first time: terminal vs. shell (>>>) vs. .py file, how to tell AI's commands from code, and 3 common beginner mistakes.

Python Basics for Vibe Coders, Part 1: Where Do You Run the Code AI Gives You?

Ask an AI to "build this in Python" and the code shows up in seconds. The hard part comes next. If you don't know where to paste that code or how to run it, you're stuck on line one. This is Part 1 of the 10-part series "Python Basics for Vibe Coders." It covers how to check your Python version and the two ways to run code: the interactive shell and a .py file. The examples are written for Python 3.15, and I ran them myself in Python 3.14.2 to check the results (the beginner-level syntax is the same in both versions).

Illustration of an empty terminal window with a single blue cursor on a dark background, next to a small recipe card whose steps are shown as a vertical line of orange dots

Key Takeaways

  • Code is a list of instructions that runs one line at a time, top to bottom, in the order it's written.
  • You type commands in your operating system's terminal. There are two ways to run Python code: the interactive shell (>>>) and a .py file.
  • Most first-time errors go away once you can tell whether something from the AI is a "terminal command" or "Python code."
  • The shell shows results right away, but everything disappears when you close it. Save code you want to keep in a .py file.

Why vibe coders need this basic step

Vibe coding means you describe what you want in plain words and let the AI write the code. But a person still has to press "run." An AI answer usually mixes two kinds of text: terminal commands like pip install ... or python app.py, and Python code like print(...) that Python itself reads. Mix them up and you get an error, then you lose time asking the AI about that error.

This series teaches just enough Python to read, run, and spot mistakes in the code AI writes for you. The goal isn't to become a developer who writes everything by hand. It's to become someone who hands work to AI and checks the results.

Code is a set of instructions, run in order

Think of a recipe: "Boil water, add the noodles, wait 3 minutes." You follow the steps in order. Python works the same way, running one line at a time from top to bottom.

Python is like a kitchen assistant who is very diligent but can't read between the lines. It does exactly what's written. It doesn't understand "a pinch" or "use your judgment," so the instructions have to be precise. When AI-written code doesn't do what you meant, Python isn't at fault. It just did what it was told. That's why you need to be able to read code.

Step 1: Check your Python version in the terminal

The terminal is a window where you give the computer text commands. On Windows, open "Terminal" or "PowerShell" from the Start menu. Once Python is installed, check the version with the command below. This is a terminal command, not Python code.

python --version

If you see something like Python 3.15.x, you're ready. If python points to a different version on Windows, check with py -3.15 --version. For installation, follow the Windows guide in the official Python docs.

Step 2: Run code line by line in the interactive shell

Type just python in the terminal and the prompt changes to >>>. This is the Python interactive shell (REPL). Any code you type here runs as soon as you press Enter.

print("Hello, Python!")
print(2 + 3 * 4)
Hello, Python!
14

Two things are worth noticing:

  • Text inside quotes is printed exactly as written. Anything outside quotes gets calculated.
  • 2 + 3 * 4 is 14, not 20. Like in math, Python does multiplication first. To change the order, use parentheses: (2 + 3) * 4.

To leave the shell, type exit(). Remember that any code you typed in the shell is gone once you close the window.

Starting with Python 3.15, Tab autocomplete suggestions in the shell are color-coded by object type. For example, type str. and press Tab to see what you can use, with each kind shown in a different color (What's New in Python 3.15).

Step 3: Save and run a .py file

When the AI gives you several lines of code, a file works better than the shell. Create a file called hello.py in an editor like Notepad or VS Code, paste in the code, and save it. Then run this terminal command from the folder where the file lives:

python hello.py

Try swapping lines in the file and you'll see the "top to bottom" rule for yourself. Swap the first and last lines, save, and run it again: the output order flips too. If you run it without saving, the old version runs, so make sure you've saved first.

3 common beginner mistakes

1. Typing Python code straight into the OS terminal

This happens when you type print("Hello") at a prompt like PS C:\...> instead of >>>. Windows has a different program named print (print.exe, used for printing to a printer), so typing this in cmd or PowerShell runs that program instead of Python. On my Windows machine, it showed an unrelated message: Unable to initialize device PRN.

  • Diagnose: Check whether the prompt is >>>.
  • Fix: Type python first and enter your code once you see >>>, or save the code in a .py file and run it with python filename.py.

2. Getting quotes, spelling, or capitalization wrong

Write Print("Hello") with a capital P and you get a NameError. Leave a quote unclosed and you get a SyntaxError. Python is case-sensitive. These mistakes are common when you retype AI code by hand, so copy and paste whenever you can.

3. Running from a folder that doesn't have the file

If python hello.py gives you No such file or directory, first check whether hello.py is in the folder your terminal currently has open. This command looks for the file in your current folder. Use cd <folder path> to move to the folder with the file, then run it again.

When an error message is long, read it from the last line up. Part 8: How to Read Error Messages covers this in detail.

Ask the AI like this to save time

  • "Split this into commands to type in the terminal and code to save in a file."
  • "Tell me how to run this in Windows PowerShell."
  • When you hit an error, paste in the command you typed, what the prompt looked like (>>> or PS ...>), and the full error message.

Check yourself

  1. What does print(2 + 3 * 4) print? → 14. Multiplication comes first: 3 * 4 = 12, then 2 + 12 = 14.
  2. What's the difference between the interactive shell and a .py file? → The shell runs each line right away, but the code disappears when you close it. To keep it, save it in a .py file.
  3. If python hello.py gives No such file or directory, what should you check first? → Whether that file is in the folder your terminal has open.

Try it yourself

Create hello.py with one line that prints your name and one line that prints the result of 12 * 7, then run it with python hello.py. If you see your name and 84 on separate lines, you did it.

print("Alex")
print(12 * 7)
Alex
84

Coming up next

To avoid retyping the same value over and over, you give it a name. The next post, Python Basics for Vibe Coders, Part 2: Variables, explains what =, the symbol you'll see most often in AI code, really means.

The full series list is at the end of Part 10.

Back to list