How to Install Python and Run Your First Program 2026
Installing Python
Download Python from the official website python.org/downloads. Always download the latest stable Python 3 release.
- Go to python.org/downloads and click "Download Python 3.x.x"
- Run the installer - check "Add Python to PATH" before clicking Install
- Verify installation by opening a terminal and running:
python --version
# Python 3.12.0
python3 --version # on macOS/Linux
# Python 3.12.0
Choosing an IDE / Editor
| Editor | Best For | Notes |
|---|---|---|
| VS Code | General development | Free, lightweight, great Python extension |
| PyCharm | Professional Python | Full-featured IDE, free Community edition |
| Jupyter Notebook | Data Science | Interactive, great for exploration |
| IDLE | Beginners | Comes bundled with Python |
| Thonny | Absolute beginners | Simple, shows variable values visually |
Running Python Code
There are three ways to run Python code:
1. Interactive Mode (REPL)
Type python in your terminal to open the interactive shell. Great for quick experiments.
>>> print("Hello, World!")
Hello, World!
>>> 2 + 3
5
>>> name = "Alice"
>>> print(f"Hello, {name}!")
Hello, Alice!
2. Script File
Create a .py file and run it with python filename.py.
# main.py
print("Hello, World!")
# Get user input
name = input("Enter your name: ")
print(f"Hello, {name}! Welcome to Python.")
# Basic arithmetic
a = 10
b = 3
print(f"{a} + {b} = {a + b}")
print(f"{a} / {b} = {a / b:.2f}")
Python Indentation
Unlike most languages, Python uses indentation (whitespace) to define code blocks - not curly braces. This is mandatory, not optional.
# Correct indentation
if True:
print("This is indented correctly") # 4 spaces
if True:
print("Nested block") # 8 spaces
# Function with indented body
def greet(name):
message = f"Hello, {name}!"
return message
# This would cause IndentationError:
# if True:
# print("Missing indent") # ERROR!
Python File Structure
A typical Python project looks like this:
my_project/
├── main.py # Entry point
├── utils.py # Helper functions
├── requirements.txt # Dependencies
├── README.md # Documentation
└── tests/
└── test_main.py # Unit tests
Level Up Your Python Skills
Master Python with these hand-picked resources
10,000+ learners
Free forever
Updated 2026
Related Python Topics