Free Interactive Python Course

Python Tutorial — Learn Python Step by Step

Key takeaway: Master Python programming from scratch — variables, loops, functions, OOP, file handling, and libraries — with clear human-readable explanations and runnable code examples.

50+ Structured Lessons
Runnable Code Examples
100% Free No Registration
Updated October 2026

Install Python on Ubuntu / Linux

Most Linux distributions include Python 3 by default. Ubuntu 20.04+ ships with Python 3.8+. Here's how to check, install, or upgrade Python on Ubuntu and Debian-based systems.

Check if Python is Already Installed

Terminal
# Check Python 3 version
python3 --version
# Output: Python 3.10.12 (or similar)

# Check pip
pip3 --version
# If not installed: "pip3: command not found"

Install or Update Python 3

Terminal
# Update package list
sudo apt update

# Install Python 3 and pip
sudo apt install python3 python3-pip python3-venv

# Verify
python3 --version
pip3 --version

# Install a specific version (e.g., 3.12) using deadsnakes PPA
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.12 python3.12-venv python3.12-dev

Set Up a Virtual Environment

Terminal
# Create a project directory
mkdir myproject && cd myproject

# Create virtual environment
python3 -m venv venv

# Activate it
source venv/bin/activate

# Your prompt changes: (venv) user@machine:~/myproject$
# Now install packages into this isolated environment
pip install flask requests pandas

# Deactivate when done
deactivate

Virtual environments are essential on Linux because system Python packages are managed by apt. Installing with pip globally can conflict with system packages. Always use a venv for project dependencies.

First Program

hello.py
#!/usr/bin/env python3
# The shebang line above lets you run the script directly: ./hello.py

import platform

print(f"Hello from {platform.system()} {platform.release()}!")
print(f"Python {platform.python_version()}")
print("Installation complete!")
$ python3 hello.py
Hello from Linux 5.15.0-91-generic!
Python 3.10.12
Installation complete!

Make Scripts Executable

Terminal
# Make a Python script executable directly
chmod +x hello.py

# Now you can run without typing python3
./hello.py

# The #!/usr/bin/env python3 shebang tells the OS which interpreter to use

Troubleshooting

ProblemSolution
pip3: command not foundsudo apt install python3-pip
externally-managed-environment error (Ubuntu 23.04+)Always use a virtual environment: python3 -m venv venv
Need newer Python than apt providesUse deadsnakes PPA: sudo add-apt-repository ppa:deadsnakes/ppa
ModuleNotFoundError after installEnsure you installed the package in the active venv, not globally
Permission deniedUse --user flag or activate a virtual environment
Done! Python 3 is ready on Ubuntu/Linux. Always use virtual environments for project isolation.

Python Programming Tutorial — Learn Python in a practical, step-by-step way. According to the official Python documentation, Python emphasizes code readability and simplicity, making it ideal for beginners.

Related tools: Python Online Compiler | Python Examples | JavaScript Tutorial | Java Tutorial

Python Career & Learning Guide

Python is the world's most popular programming language for beginners, data science, AI/ML, web development, and automation. This tutorial teaches Python step-by-step with clear explanations and runnable code examples in our free Python Compiler.

Why Learn Python in 2026?

  • #1 Most Popular Language: Ranked first on TIOBE, Stack Overflow, and GitHub.
  • AI and Data Science: The primary language for machine learning (TensorFlow, PyTorch, scikit-learn) and data analysis (Pandas, NumPy).
  • Web Development: Django and Flask power scalable backends at companies like Instagram and Spotify.
  • Automation & Scripting: Automate files, emails, web scraping, and data processing in minutes.

Python vs Other Languages

FeaturePythonJavaJavaScriptC++
SyntaxVery clean, readableVerboseModerateComplex
TypingDynamic, strongStatic, strongDynamic, weakStatic, strong
Best ForAI/ML, Data, WebEnterprise, AndroidWeb Frontend/BackendSystems, Games
Learning Time2–4 weeks basics4–6 weeks basics3–4 weeks basics8–12 weeks basics

Frequently Asked Questions

Do I need prior programming experience to learn Python?

No! Python is specifically designed to be beginner-friendly. This tutorial starts from zero and builds up gradually.

Which Python version should I use?

Python 3.10+ is recommended. All examples in this tutorial use Python 3 syntax.

Is this Python tutorial completely free?

Yes, 100% free with no registration or sign-up required. Access all lessons and code examples anytime.