Skip to main content

Introduction and Getting Started

What You'll Learn

By the end of this lesson you will be able to install Python, open a terminal, and run your first Python program.

Why Python?

Python is one of the most beginner-friendly programming languages in the world. It uses plain English words, and you can get something working in minutes.

Python is used for:

  • Web development (Instagram, Pinterest)
  • Data science and AI (ChatGPT, self-driving cars)
  • Automation (renaming files, sending emails, scraping websites)
  • Server scripts (managing Linux servers, cron jobs)

Step 1 — Check If Python Is Already Installed

Open your terminal and type:

python3 --version

If you see something like Python 3.11.4, you're ready. Skip to Step 3.

Step 2 — Install Python

Linux (Ubuntu/Debian):

sudo apt update
sudo apt install python3 python3-pip -y

macOS:

brew install python3

Windows: Download the installer from python.org and check "Add Python to PATH" during installation.

Step 3 — Write Your First Program

Create a file called hello.py:

print("Hello, World!")

Run it:

python3 hello.py

Output:

Hello, World!

🎉 Congratulations — you just ran your first Python program!

Step 4 — Try the Python REPL

The REPL (Read-Evaluate-Print Loop) lets you run Python one line at a time. Start it:

python3

You'll see >>>. Type:

>>> print("Hello!")
Hello!
>>> 2 + 2
4
>>> exit()

Type exit() to quit the REPL.

How Python Programs Work

You write code in a .py file

Python reads and runs each line top to bottom

Results appear in the terminal

Python is an interpreted language — it doesn't need to be compiled before running. This makes it fast to experiment with.

Your First Multi-Line Program

# This is a comment — Python ignores lines starting with #
name = "Alice"
age = 25

print("Name:", name)
print("Age:", age)
print("In 10 years:", age + 10)

Output:

Name: Alice
Age: 25
In 10 years: 35

Common Mistakes

MistakeError You'll SeeFix
Typing python instead of python3command not foundUse python3 on Linux/Mac
Forgetting parentheses in printSyntaxErrorWrite print("hello"), not print "hello"
Wrong quotesSyntaxErrorUse " or ' consistently, not mixed
Typos in filenamesNo such fileCheck spelling with ls first

Quick Reference

# Run a file
# python3 filename.py

# Print text
print("Hello!")

# Print a number
print(42)

# Print multiple things
print("Age:", 25)

# Comment a line (Python ignores it)
# This is a comment

Practice Exercises

  1. Hello You: Change "Hello, World!" to print your own name.
  2. Math: Write a program that prints the result of 100 * 365.
  3. Multi-line: Write a program with 3 print() statements that each print something different.

What's Next

Lesson 2: Syntax, Statements, and Output