Python Setup for Beginners: Install and Run Your First Program

Build a clean Python project from scratch, verify the interpreter, run a complete program and diagnose the setup mistakes that catch most beginners.

KnowledgeGate Team

Exam prep & CS education

Updated 29 Aug 20265 min read

Python installation is useful only when you can prove which interpreter, environment and file ran. Complete the Introduction and Setup in Python tutorial with examples if Python is not installed yet. Then collect four observable results: a Python 3 version, a .venv interpreter path, a visible hello.py file and the program's exact output. Any failed result identifies the next repair.

Prove a Python setup with four observable results

A usable setup produces four pieces of evidence:

  • Launcher: the version command begins with Python 3.

  • Environment:sys.executable points inside python-start/.venv.

  • File location:dir or ls shows hello.py in the current folder.

  • Execution:python hello.py prints Asha planned 4 topics for 100 minutes.

Start with a neutral interpreter test that does not depend on a saved file:

python -c "print(6 * 7)"

A pass prints 42. The saved-program gate later must print Asha planned 4 topics for 100 minutes. Explore the Coding & Skill Development Courses only after all four setup gates pass.

Prove the Python 3 launcher before creating a project

Obtain Python 3 from Python's official website or use your operating system's supported installation route. On Windows, the installer must make a launcher available to a newly opened terminal. Try:

py --version
python --version

Use the command that works on your machine. On macOS or Linux, try:

python3 --version

A successful result begins with Python 3; the remaining digits vary by machine. Now run a readiness check.

Windows:

py -c "print('Python is ready')"

macOS or Linux:

python3 -c "print('Python is ready')"

The exact output must be:

Python is ready

If the terminal says the command was not found or not recognised, the problem is the launcher or PATH, not print(). Reopen the terminal first, try the suitable launcher for your operating system, then revisit the installation settings.

Prove project isolation with sys.executable

In Windows Command Prompt, enter these commands one by one:

mkdir python-start
cd python-start
py -m venv .venv
.venv\Scripts\activate.bat

On macOS or Linux, use:

mkdir python-start
cd python-start
python3 -m venv .venv
source .venv/bin/activate

python-start is now your current project folder. .venv contains its isolated environment, and (.venv) at the start of the prompt normally signals that it is active. You do not need any third-party package for this lesson.

Check which interpreter will run:

python -c "import sys; print(sys.executable)"

The returned path should include both python-start and .venv. Its full form depends on your username and operating system, so do not compare it with somebody else's absolute path.

Run, trace and change one saved Python program

Create hello.py in your editor and save this exact program:

student = "Asha"
topics = 4
minutes_per_topic = 25

total_minutes = topics * minutes_per_topic
print(f"{student} planned {topics} topics for {total_minutes} minutes.")

From the activated environment, run:

python hello.py

The output is:

Asha planned 4 topics for 100 minutes.

Trace it before moving on. student stores "Asha", topics stores 4, and minutes_per_topic stores 25. Python calculates 4 * 25 = 100 and stores that result in total_minutes. The f-string then inserts Asha, 4 and 100 into the sentence.

Now change only topics = 4 to topics = 6, save the file and predict the result. The calculation becomes 6 * 25 = 150, so the new output is:

Asha planned 6 topics for 150 minutes.

This change proves that Python executed the newly saved instructions.

Execution trace of hello.py: values stored, 4 times 25 gives 100, and the planned-minutes sentence printed to the terminal.

Use the REPL as a control test

With .venv active, start the REPL by entering python. Try:

>>> 7 * 6
42
>>> name = "Ravi"
>>> f"Hello, {name}"
'Hello, Ravi'

The REPL is useful for a quick calculation or syntax check. A saved file preserves a complete set of instructions that you can edit and rerun. Enter exit() to leave the REPL, then use python hello.py in the terminal again.

The >>> symbols are the REPL's prompt, not Python source code. Copying >>> 7 * 6 into hello.py causes a syntax failure. A saved line should be only 7 * 6, or print(7 * 6) when you want visible output.

Diagnose Python setup failures in dependency order

Check failures in dependency order: launcher, selected interpreter, file location, then saved program.

  • Launcher not found: reopen the terminal, try the operating system's appropriate launcher, then check the installation and PATH.

  • Python cannot open hello.py: enter dir on Windows or ls on macOS or Linux. If the file is absent, use cd to return to python-start.

  • Wrong interpreter: if sys.executable does not point inside .venv, activate the environment again.

  • Old output: after changing topics from 4 to 6, the minutes must change from 100 to 150. If they do not, save hello.py and rerun the same command.

Indentation is part of Python's syntax. This code is wrong because the second line is not indented:

if total_minutes > 60:
print("Long session")

It can raise IndentationError. Repair it with four spaces:

total_minutes = 100
if total_minutes > 60:
    print("Long session")

Because 100 is greater than 60, the corrected code prints Long session.

Troubleshooting decision tree: check the readiness message, the .venv interpreter, and hello.py's location, then rerun the program.

Test the setup with small predicted results

Predict each result before running the command:

  1. print("7" * 3) prints 777 because Python repeats the string three times.

  2. print(2 + 3 * 4) prints 14 because multiplication happens first: 3 * 4 = 12, then 2 + 12 = 14.

  3. print(type(25).__name__) prints int because 25 is an integer.

Next, complete two setup exercises:

  • Create check.py with hours = 3, minutes = hours * 60 and print(minutes). The required output is 180 because 3 * 60 = 180.

  • In hello.py, set student to "Ravi", topics to 5 and minutes_per_topic to 20. Predict and confirm Ravi planned 5 topics for 100 minutes. because 5 * 20 = 100.

For a repair exercise, run Print("Ready"). It raises NameError because names are case-sensitive. Change it to print("Ready"), which outputs Ready.

Repeat the same prediction-and-repair loop with unfamiliar expressions: predict first, run second and explain any mismatch before moving on.

Repeatable Python setup checklist and next step

The complete process is six steps:

  1. Install Python 3.

  2. Verify the operating system's appropriate launcher.

  3. Create python-start.

  4. Activate .venv.

  5. Save hello.py.

  6. Run it until you see Asha planned 4 topics for 100 minutes.

Open a fresh terminal and repeat the process once without looking at the commands. That repetition turns a list of instructions into a setup you understand.

The Python Programming course is the immediate structured next step. Consider DSA Using Python later, after variables, control flow, functions and collections feel comfortable. For optional CS foundations, read Number Systems and Base Conversions Explained.