Python: Install Python, VS Code & Write Your First Program (Hello World)

Writing your first program in Python takes only a few minutes once the tools are in place. This guide gets Python 3.14.6 and Visual Studio Code (VS Code) running on any operating system, then walks you through writing, saving, and running that program. By the end of this post you will have a working development setup and a mini calculator you built yourself.

“The best way to learn programming is to program.”

Brian Kernighan, The C Programming Language

Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Beginner | Reading Time: 20 minutes

Here is what you will have by the end of this post:

▶ What your terminal will look like

$ python hello.py
Hello, World!

$ python calculator.py
=== Rahul's Mini Calculator ===
Enter first number: 15
Enter second number: 4
15.0 + 4.0 = 19.0
15.0 - 4.0 = 11.0
15.0 * 4.0 = 60.0
15.0 / 4.0 = 3.75

That is real Python output from real code you will write in the next 18 minutes. Two programs: a first program that prints Hello World, then a working calculator. Let’s get your machine set up.

What We Are Building

Two programs today. Your first program is the traditional Hello World, one line of code that proves your entire setup works. Then a mini calculator that takes two numbers from the user and shows addition, subtraction, multiplication, and division. Both run in your terminal.

This is a Project/Build tutorial. You will follow step-by-step instructions, and after each step you will have something that runs. No dead code. No “we will use this later” sections. Every step produces visible output.

Step 1: Install Python

Go to python.org/downloads. You will see a big yellow button that says “Download Python 3.14.6.x” (the exact patch number changes, so any 3.14 version works). Click it.

Windows

  1. Run the downloaded .exe installer.
  2. CRITICAL: Check the box that says “Add python.exe to PATH” at the bottom of the first screen. This is the single most important checkbox in the entire installation. If you miss it, the python command will not work in your terminal.
  3. Click “Install Now” (the default settings are fine).
  4. When it finishes, click “Disable path length limit” if Windows offers it. This prevents a rare but annoying problem with deeply nested folders.
  5. Close the installer.

macOS

  1. Run the downloaded .pkg installer.
  2. Click through the steps. The defaults are fine.
  3. macOS may have an older Python pre-installed. Ignore it. The installer puts Python 3.14.6 in a separate location. You will use python3 as the command (not python).
  4. After installation, open Terminal and run python3 --version to verify.

Linux (Ubuntu/Debian)

Most Linux distributions come with Python pre-installed, but it might be an older version. Open your terminal and check:

📄 Terminal: check existing Python version

python3 --version

If you see Python 3.14.6.x, you are done. If it shows an older version or is not found, install it:

📄 Terminal: install Python 3.14.6 on Ubuntu/Debian

sudo apt update
sudo apt install python3.14 python3.14-venv python3-pip

If apt says it cannot find python3.14, your Ubuntu release is older than the package. Add the deadsnakes PPA first with sudo add-apt-repository ppa:deadsnakes/ppa, then run the two commands above again. On Fedora, use sudo dnf install python3.14. On Arch, use sudo pacman -S python.

Step 2: Verify Python Works

Open your terminal (you learned how in terminal setup tutorial) and type:

📄 Terminal: verify Python installation

python --version

▶ Expected Output

Python 3.14.6

The exact patch number (3.14.5, 3.14.6, etc.) does not matter. As long as it starts with 3.14, you are good. On macOS and Linux, you might need to type python3 --version instead of python --version.

If you see ’python’ is not recognized on Windows, you missed the “Add to PATH” checkbox. Uninstall Python, reinstall, and this time check that box. It is the number one installation mistake.

Step 3: Install VS Code

You can write Python in any text editor. Even Notepad. But that is like chopping vegetables with a butter knife: it works, just slowly and painfully. A proper code editor is the chef’s knife, and it gives you syntax highlighting (colors that make code readable), error detection, an integrated terminal, and auto-completion. VS Code is free, fast, and used by most Python developers.

  1. Go to code.visualstudio.com and download the installer for your OS.
  2. Run the installer. On Windows, check “Add to PATH” and “Register Code as an editor for supported file types.”
  3. Open VS Code after installation.
  4. Go to the Extensions panel (the square icon on the left sidebar, or press Ctrl+Shift+X).
  5. Search for “Python” by Microsoft. It should be the first result with millions of installs. Click Install.
  6. That is it. The Python extension gives you IntelliSense (smart auto-completion), linting (error highlighting), and a built-in way to run Python files.

Checkpoint: You now have Python 3.14.6 and VS Code installed. Your machine is ready for your first program.

Step 4: Hello World

Time to write your first program. Open VS Code, then open the terminal inside VS Code by pressing Ctrl+` (backtick, the key above Tab). Navigate to a folder where you want to keep your Python projects:

📄 Terminal: create a project folder and navigate into it

mkdir python-projects
cd python-projects

Now create a new file. You can either use the VS Code file explorer (File → New File) or do it from the terminal:

📄 Terminal: create your first Python file

code hello.py

This opens a new file called hello.py in VS Code. The .py extension tells your operating system (and VS Code) that this is a Python file. Think of it like the label on a jar in your kitchen: the jar holds the contents, but the label is what tells everyone it is sugar and not salt. The .py label is what tells your computer to treat the file as Python. Type this single line:

📄 hello.py: your first Python program

print("Hello, World!")

Save the file (Ctrl+S). Now run it from the terminal:

📄 Terminal: run your first Python program

python hello.py

▶ Output

Hello, World!

What happened here: You told Python to run the file hello.py. Python read the single instruction inside (print("Hello, World!")) and executed it. The print() function sent the text to your terminal. That is it. You have written and run a real Python program.

You can also run the file directly in VS Code by clicking the green play button (▷) in the top-right corner. It does the same thing as typing python hello.py in the terminal.

Checkpoint: If you see Hello, World! in your terminal, your first program ran perfectly. Congratulations, you are officially a programmer.

How Python Executes Your Code

When you ran your first program with python hello.py, a surprising amount happened behind the scenes. Python does not send your text file directly to the Central Processing Unit (CPU). There are several stages in between.

No errorsSomething wentwrong📝 You Write Codehello.py🔍 Lexer / TokenizerBreaks code into tokens:print, (, ‘Hello’, )🌳 ParserBuilds an Abstract SyntaxTree(AST) from tokens⚙️ CompilerConverts AST to bytecode(.pyc files in __pycache__)🐍 Python Virtual Machine(PVM)Executes bytecodeinstruction by instructionError atany stage?📺 OutputHello, World! Error MessageSyntaxError, NameError,TypeError, etc.Python Execution: How hello.py Goes from Source to Bytecode to Output

You do not need to memorize these stages. The important takeaway is this: Python is not a purely interpreted language. It compiles your code to an intermediate format called bytecode (that is what the __pycache__ folder holds), and then a virtual machine runs that bytecode. This is why Python is sometimes described as “compiled to bytecode, then interpreted.”

Here is the everyday version. Think of a recipe written in English. Before a busy kitchen can cook from it, someone rewrites the recipe as a short numbered checklist that any cook can follow fast. The English recipe is your .py file, the numbered checklist is the bytecode, and the cook racing through the checklist is the virtual machine. You wrote it once in human form, and Python quietly translated it into a form that runs quickly.

For now, think of it as: you write text, Python reads it, your computer does the work, and you see results. Those layers in between are exactly why Python can give you such helpful error messages. It catches problems at each stage and tells you which one went wrong.

REPL vs Script Mode

Python gives you two ways to run code. You have already used script mode, that is, writing code in a .py file and running it. The other way is the REPL (Read, Eval, Print, Loop), an interactive mode where you type one line at a time and Python shows the result straight away.

Quick way to picture it. The REPL is like texting back and forth with a friend: you send one line, you get one reply, you send the next. Script mode is like writing a whole letter and posting it: you put down everything first, then send it all at once and read the full reply at the end.

Open your terminal and type python (or python3 on macOS/Linux) without any filename:

📄 Terminal: enter the Python REPL

python

▶ Output

Python 3.14.6 (tags/v3.14.6:c63aec6, Jun 10 2026, 10:26:10) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

That >>> prompt means Python is waiting for you to type something. Try a few lines. The string example below glues together the first and last name of an imaginary user named Aditi Verma:

📄 Python REPL: interactive experimentation

>>> 2 + 3
5
>>> "Aditi" + " " + "Verma"
'Aditi Verma'
>>> print("Hello from the REPL!")
Hello from the REPL!
>>> 100 / 7
14.285714285714286

What happened here: Each line you typed was Read, Evaluated, and the result Printed, then the Loop repeated and waited for your next line. That is where the name REPL comes from. Notice that 2 + 3 showed 5 without needing print(). The REPL displays the result of an expression on its own. In a script file you would need print(2 + 3) to see anything, because a script only shows what you explicitly print.

To exit the REPL, just type exit (since Python 3.13 the new REPL accepts it without parentheses, though exit() still works). You can also press Ctrl+Z then Enter on Windows, or Ctrl+D on macOS/Linux.

When to use which: Use the REPL for quick experiments, like checking how a function works, testing a calculation, or debugging a small piece of logic. Use script mode for anything you want to save, reuse, or share. Everything you build in this series will be in script mode, but you will often pop into the REPL to test an idea in a few seconds.

Step 5: Build a Mini Calculator

A first program proves your setup works. Now let’s build something genuinely useful: a calculator that asks the user for two numbers and shows all four basic operations. It works like a billing counter at a shop: the clerk asks what you bought, does the math, and reads the total back to you. Ask, compute, answer.

Create a new file called calculator.py. The banner in the first line carries my name (I am Rahul, the author of this series); swap in your own name to make the program yours:

📄 calculator.py: a mini calculator that takes user input

# Rahul's Mini Calculator
# Takes two numbers and shows all four operations

print("=== Rahul's Mini Calculator ===")

# Get input from the user
first = input("Enter first number: ")
second = input("Enter second number: ")

# Convert text input to numbers
# input() always returns text, so we need float() to make it a number
num1 = float(first)
num2 = float(second)

# Perform calculations
addition = num1 + num2
subtraction = num1 - num2
multiplication = num1 * num2
division = num1 / num2

# Display results
print(str(num1) + " + " + str(num2) + " = " + str(addition))
print(str(num1) + " - " + str(num2) + " = " + str(subtraction))
print(str(num1) + " * " + str(num2) + " = " + str(multiplication))
print(str(num1) + " / " + str(num2) + " = " + str(division))

Run it:

📄 Terminal: run the calculator

python calculator.py

▶ Output (user types 15 and 4)

=== Rahul's Mini Calculator ===
Enter first number: 15
Enter second number: 4
15.0 + 4.0 = 19.0
15.0 - 4.0 = 11.0
15.0 * 4.0 = 60.0
15.0 / 4.0 = 3.75

What happened here: Let’s walk through it line by line.

  • input("Enter first number: ") shows the prompt text and then waits for the user to type something and press Enter. Whatever they type comes back as a string (text), even if it looks like a number.
  • float(first) converts the text "15" into the number 15.0. We use float() instead of int() so the calculator works with decimals too. This is called type conversion, and you will learn all about it in the type conversion tutorial.
  • The four calculation lines are straightforward arithmetic: +, -, *, and /.
  • str(num1) converts the number back to text so we can glue it together with the + and = characters. You cannot add a number and a string directly in Python, so it would crash without this conversion.

Checkpoint: If your calculator runs and shows the four results, you have just built your first interactive Python program. It takes input, processes it, and produces output, which is exactly the pattern from the What is Programming tutorial.

A Note on Virtual Environments

As you progress through this series, you will install third-party libraries using pip (Python’s package manager). When that time comes, you should always use a virtual environment, an isolated sandbox that keeps each project’s libraries separate from each other. Think of it like packing each meal in its own tiffin box: the dal from one lunch never leaks into the fruit salad of another.

You do not need virtual environments right now. For posts 001 through 038 (all of Part 1), you will use only Python’s built-in features. But when we reach the virtual environments tutorial, we will cover this properly. For now, just remember: always use venv. We will explain what that means and why it matters when the time comes.

Alternative: Jupyter Notebook

There is another way to write Python that is popular in data science: Jupyter Notebook. Instead of writing code in a .py file and running the whole thing, Jupyter lets you write code in small “cells” and run each cell independently. It works like a school lab notebook: you do one experiment, note the result right below it, then move on to the next. You see the output directly below each cell, which makes it great for experimentation and data visualization.

You do not need Jupyter for this series until Part 4 (Data Science). When we get there, the ML environment setup tutorial will walk you through setting it up. For now, VS Code and the terminal are all you need.

If you are curious and want to try Jupyter right now, VS Code actually has built-in Jupyter support through its Python extension. Just create a file with the .ipynb extension and start adding cells.

What Could Go Wrong

“python” is not recognized as an internal or external command

This means Python is not in your system’s PATH. On Windows, uninstall Python and reinstall with the “Add python.exe to PATH” checkbox checked. On macOS/Linux, try python3 instead of python.

SyntaxError: invalid syntax

Double-check your code character by character. Common culprits: missing closing parenthesis, using curly quotes (“ ”) instead of straight quotes (” “), or copying code from a PDF that added invisible characters. Type the code yourself instead of copying.

VS Code says “No Python interpreter selected”

Press Ctrl+Shift+P, type “Python: Select Interpreter”, and pick the Python 3.14.6 installation. If nothing appears, VS Code cannot find Python, so go back and check your installation.

The calculator crashes when I type a letter instead of a number

That is expected. float("abc") crashes with a ValueError. You will learn how to handle this gracefully in the exception handling tutorial. For now, just type numbers.

Division by zero crashes the program

Also expected. If you enter 0 as the second number, Python raises a ZeroDivisionError. Again, exception handling (covered in the exception handling tutorial) will teach you how to prevent this. For now, don’t divide by zero.

Common Mistakes

Mistake 1: Forgetting to save the file before running

You edit hello.py in VS Code but forget to press Ctrl+S. Then you run python hello.py and see the old output. Always save before running. VS Code shows a white dot on the tab name when a file has unsaved changes.

Mistake 2: Running python hello.py from the wrong folder

Say a learner named Anvay keeps his file in C:\Users\Anvay\python-projects but his terminal is sitting in C:\Users\Anvay. Python will say can’t open file ’hello.py’: No such file or directory. Use cd python-projects to navigate to the right folder first, or give the full path: python python-projects/hello.py.

Mistake 3: Using Print instead of print

Python is case-sensitive. print() works. Print() gives you NameError: name ’Print’ is not defined. Every built-in function in Python is lowercase. Notice the friendly part at the end of the error: modern Python even guesses what you meant and adds “Did you mean: ’print’?” to point you straight at the fix.

📄 case_matters.py: Python is case-sensitive

# This works
print("hello")

# This crashes
Print("hello")  # NameError: name 'Print' is not defined

▶ Output

hello
Traceback (most recent call last):
  File "case_matters.py", line 5, in <module>
    Print("hello")  # NameError: name 'Print' is not defined
    ^^^^^
NameError: name 'Print' is not defined. Did you mean: 'print'?

Best Practices

  • DO type the code yourself instead of copying and pasting. Your fingers need to build muscle memory for Python syntax.
  • DO keep all your Python files in one project folder. Organization matters early.
  • DO use meaningful filenames. calculator.py is better than test.py or aaa.py.
  • DO use the VS Code integrated terminal instead of a separate terminal window. Having your code and terminal in the same window speeds up your workflow.
  • DON’T name your file python.py. It will conflict with Python itself and cause mysterious import errors later.
  • DON’T worry about the __pycache__ folder that appears. It contains compiled bytecode (the .pyc files from the diagram above). Python creates it automatically and you can ignore it.

Conclusion

You installed Python 3.14.6, set up VS Code with the Python extension, wrote your first program, understood REPL vs script mode, and built a working calculator. That is a real development environment, the same tools professional developers use every day.

The key concepts from this post: Python compiles your code to bytecode before running it. The REPL is for quick experiments, script mode is for real programs. input() always returns text, so you need float() or int() to convert it to a number. And print() is lowercase, always.

In the next post we keep building on this with Python variables: how naming and assignment work, and the memory model behind them. Now that you have actually written and run Python code, that will land differently than it would have on day one.

Want to see everything this series covers, from these first steps all the way to AI and machine learning? Browse the full index at the Python + AI/ML tutorial series home.

Practice Exercises

  1. Exercise 1: Recreate your first program from memory: a script that prints Hello World, run from the terminal.
  2. Exercise 2: Modify your Hello World script to ask for the user’s name with input() and print a personalized greeting, so if someone named Anvi types her name, it prints Hello, Anvi!.
  3. Exercise 3: Create a script printing a simple ASCII art pattern using multiple print() calls.

Frequently Asked Questions

Should I install Python 3.13 or 3.14?

Install Python 3.14.6. It is the latest stable release at the time of writing (it was released in October 2025 and is now in bugfix maintenance), and every example in this series is tested on it. If you ever hit a library that has not shipped a 3.14 wheel yet, the safe fallback is the newest 3.13 patch (3.13.14 at the time of writing), which has the widest library compatibility. We will call out anything 3.14-specific with a “Since 3.14” note when it matters.

Can I use PyCharm instead of VS Code?

Yes. PyCharm is another excellent Python IDE (Integrated Development Environment), especially the free Community Edition. However, this series uses VS Code because it is lighter, free, and works for every programming language. If you already use PyCharm and like it, keep using it. The Python code is the same regardless of your editor.

What is the difference between python and python3 commands?

On Windows, the installer usually sets up python to point to your Python 3.14.6 installation. On macOS and Linux, python might point to an old Python 2 or not exist at all, so you use python3 instead. Both run the same Python, it is just a naming difference. If python --version shows 3.14, use python. Otherwise, use python3.

What is __pycache__ and can I delete it?

The __pycache__ folder contains compiled bytecode files (.pyc) that Python creates to speed up later runs. You can safely delete it, and Python will recreate it the next time you run your script. It is commonly added to .gitignore in version-controlled projects.

Why does input() return a string even when I type a number?

The input() function reads whatever the user types as text (a string). It has no way to know whether you intended “42” to be a number or a postal code. You explicitly convert it using int() for whole numbers or float() for decimals. This explicit conversion is by design, because Python prefers being explicit over guessing.

Do I need to learn the terminal or can I just use VS Code buttons?

VS Code’s play button works fine for running simple scripts. But as you progress, you will need the terminal for installing libraries (pip install), managing virtual environments, running tests, using Git, and debugging. Learning the terminal now (as we covered in the terminal setup tutorial) saves you significant time later.

Interview Questions on Python Setup and Your First Program

These come from real screens and onsites. Practice answering before you read each answer.

Q: Is Python a compiled language or an interpreted language?

Both, in a specific way. CPython (the standard Python you installed) first compiles your source code to bytecode, the .pyc files stored in __pycache__, and then the Python Virtual Machine (PVM) interprets that bytecode instruction by instruction. So the accurate answer is “compiled to bytecode, then interpreted.” Saying “Python is purely interpreted” is a common oversimplification interviewers like to probe.

Q: What actually happens, step by step, when you run python hello.py?

The lexer breaks your source text into tokens, the parser builds an Abstract Syntax Tree (AST) from those tokens, the compiler turns the AST into bytecode, and the PVM executes that bytecode. If any stage fails, Python stops and reports an error from that stage, which is why a SyntaxError appears before a single line runs, while a NameError appears only when the bad line is actually executed.

Q: You are on a fresh Windows laptop, you type python --version and get “python is not recognized”. What do you check first?

First suspect PATH: the installer’s “Add python.exe to PATH” checkbox was probably left unchecked. Try py --version, because the Windows py launcher is registered separately and often works even when python does not. If both fail, Python is not installed at all; if only py works, reinstall Python with the PATH checkbox checked or add the install folder to PATH manually.

Q: A user runs your calculator, enters 12,5 for the first number, and the program crashes with ValueError: could not convert string to float. Why, and what would you do about it?

input() returns the raw text "12,5", and float() only accepts a dot as the decimal separator, so the comma makes the conversion fail. The quick fix is first.replace(",", ".") before converting; the proper fix is wrapping the conversion in a try/except ValueError block and asking the user to re-enter the value. The underlying lesson is that user input is always a string and can always be malformed.

Q: When would you use the Python REPL instead of writing a script?

The REPL (Read, Eval, Print, Loop) is for throwaway experiments: checking what a function returns, testing a quick calculation, or poking at an object while debugging. Scripts are for anything you want to save, rerun, or share. A practical difference worth mentioning: the REPL echoes the value of a bare expression automatically, while a script only shows what you explicitly print().

Q: Your teammate’s script prints 15.0 + 4.0 = 19.0 but the requirement was 15 + 4 = 19. What changed the numbers, and how do you fix it?

The script converts input with float(), which always produces a decimal value, so "15" becomes 15.0. If the program only ever needs whole numbers, convert with int() instead and the output shows 15. The trade-off is that int("3.5") raises a ValueError, so choose the conversion based on what input you must accept, not on what looks nicer.

More in this series:

Related Topics You Might Like:

This post is part of the Python + AI/ML Cookbook series on TechnoScripts.com

Previous: Python: How to Open the Terminal, Files, Folders, and Your First Tool

Next: Python Variables: Naming, Assignment, and the Memory Model

Series Home: Python + AI/ML Tutorial Series

RahulAuthor posts

Avatar for Rahul

Rahul is a passionate IT professional who loves to sharing his knowledge with others and inspiring them to expand their technical knowledge. Rahul's current objective is to write informative and easy-to-understand articles to help people avoid day-to-day technical issues altogether. Follow Rahul's blog to stay informed on the latest trends in IT and gain insights into how to tackle complex technical issues. Whether you're a beginner or an expert in the field, Rahul's articles are sure to leave you feeling inspired and informed.

No comment

Leave a Reply

Your email address will not be published. Required fields are marked *