Tutorials Logic, IN +91 8092939553 info@tutorialslogic.com
Navigation
Home About Us Contact Us Blogs FAQs
Tutorials
All Tutorials
Services
Academic Projects Resume Writing Interview Questions Website Development
Compiler Tutorials

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.

  1. Go to python.org/downloads and click "Download Python 3.x.x"
  2. Run the installer - check "Add Python to PATH" before clicking Install
  3. Verify installation by opening a terminal and running:
Verify Installation
python --version
# Python 3.12.0

python3 --version   # on macOS/Linux
# Python 3.12.0

Choosing an IDE / Editor

EditorBest ForNotes
VS CodeGeneral developmentFree, lightweight, great Python extension
PyCharmProfessional PythonFull-featured IDE, free Community edition
Jupyter NotebookData ScienceInteractive, great for exploration
IDLEBeginnersComes bundled with Python
ThonnyAbsolute beginnersSimple, 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.

Python REPL
>>> 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.

First Python Script
# 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.

Indentation Rules
# 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:

Project Structure
my_project/
├── main.py           # Entry point
├── utils.py          # Helper functions
├── requirements.txt  # Dependencies
├── README.md         # Documentation
└── tests/
    └── test_main.py  # Unit tests

Ready to Level Up Your Skills?

Explore 500+ free tutorials across 20+ languages and frameworks.