What is Python?

Python is one of the most popular programming languages in the world. Created by Guido van Rossum and first released in 1991, Python is known for its clean, readable syntax that makes it an excellent first language to learn.

Python is used everywhere: web development, data science, artificial intelligence, automation, cybersecurity, and more. Companies like Google, Netflix, Instagram, and NASA all use Python extensively.

💡
Why Python?

Python reads almost like English, has a massive library ecosystem, and has one of the largest developer communities. If you can only learn one language, Python is the best starting point.

Installing Python

Most Linux distributions come with Python pre-installed. Let's check:

python3 --version

You should see something like Python 3.10.12 or higher. If Python is not installed:

Ubuntu / Debian

sudo apt update
sudo apt install python3 python3-pip

Fedora

sudo dnf install python3 python3-pip

Windows

Download the installer from python.org and run it. Make sure to check "Add Python to PATH" during installation.

⚠️
Python 2 vs Python 3

Always use python3 (not python). Python 2 reached end-of-life in 2020 and should not be used for new projects.

The Python Interactive Shell

Python comes with an interactive shell (also called REPL) where you can type code and see results immediately. Start it by typing:

python3

You'll see a prompt like this:

Python 3.10.12 (main, Nov 20 2023, 15:14:05)
[GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

The >>> prompt means Python is waiting for your input.

Your First Python Program

In the Python shell, type the following and press Enter:

>>> print("Hello, World!")
Hello, World!

Congratulations — you just ran your first Python program! The print() function displays text on the screen.

Let's try a few more things:

>>> print(2 + 3)
5
>>> print("Python is " + "awesome")
Python is awesome
>>> print(10 * 5)
50

To exit the interactive shell, type exit() or press Ctrl + D.

Writing a Python Script

While the interactive shell is great for quick experiments, real programs are saved as .py files. Let's create one:

1
Create a new file called hello.py using any text editor:
nano hello.py
2
Type the following code:
# My first Python script
print("Hello, World!")
print("Welcome to Python programming!")

name = "Learner"
print("Hello, " + name + "!")
3
Save and run it:
python3 hello.py

Output:

Hello, World!
Welcome to Python programming!
Hello, Learner!
💡
Comments in Python

Lines starting with # are comments — they're ignored by Python and exist only to explain the code to humans. Use them liberally!

Python's Key Features

  • Readable syntax: Python uses indentation instead of braces, making code naturally clean and consistent.
  • Interpreted language: No compilation step — write code and run it immediately.
  • Dynamically typed: You don't need to declare variable types — Python figures it out.
  • Huge standard library: Batteries included — hundreds of built-in modules for common tasks.
  • Cross-platform: The same Python code runs on Linux, Windows, and macOS.

Summary

In this tutorial, you learned:

  • What Python is and why it's worth learning
  • How to install Python and verify your installation
  • How to use the Python interactive shell
  • How to write and run your first Python script
  • Python's key features that make it beginner-friendly
🎉
Great start!

You've written your first Python code! In the next tutorial, you'll learn about variables and data types — the building blocks of every Python program.