TracksPractical Coding FoundationsUsing the TerminalRunning Programs From the Terminal(6 of 6)

Running Programs From the Terminal

The terminal is where your code comes to life. Writing code creates a file; running it makes the computer actually execute your instructions. Understanding this execution process helps you debug problems and work more effectively.

Running Python Scripts

To run a Python file, use the python3 command followed by the filename:

On Windows, you might use python instead of python3:

python hello.py

Make sure you're in the same folder as your script, or provide the full path: python3 /path/to/hello.py.

Running JavaScript With Node.js

For JavaScript files, use the node command:

What Happens When You Run a Program

When you execute a command like python3 script.py, several things happen:

  1. The shell finds the program — It locates the Python interpreter on your system
  2. The interpreter loads your file — Your code is read from disk into memory
  3. Instructions execute — The interpreter processes your code line by line
  4. Output appears — Any print() statements display in the terminal
  5. The program ends — Control returns to the terminal prompt

This entire process might take milliseconds for simple scripts.

Understanding Exit Codes

Every program finishes with an exit code — a number indicating success or failure:

  • 0 — Success (everything worked)
  • Non-zero — Error (something went wrong)

You usually don't see exit codes directly, but they matter for automation and scripting. You can check the last exit code:

echo $?    # Shows exit code of last command
$LASTEXITCODE    # Shows exit code in PowerShell

When Things Go Wrong

If your program has an error, you'll see an error message instead of normal output:

These error messages tell you what went wrong and where. Learning to read them is a crucial debugging skill you'll develop throughout this track.

The Execution Cycle

As a developer, you'll repeat this cycle constantly: edit code, save, run, observe results, repeat. The terminal makes this cycle fast and efficient — no clicking through menus, just type and run.

See More

Further Reading

You need to be signed in to leave a comment and join the discussion