Cristhian Villegas
Backend8 min read0 views

Python Course #1: Installing Python and Your First Program

Python Course #1: Installing Python and Your First Program

Welcome to the Python Course - Part 1 of 10

Python Logo

Welcome to the Python Course from Scratch! This is article 1 of 10 in a series designed to teach you how to program in Python with no prior experience required. If you have never written a single line of code, you are in the right place.

In this first article, we will install Python on your computer, write your first program, and get familiar with the tools you will use throughout the course. By the end of this article, you will have everything ready to start coding.

📌 Note: This course is made up of 10 articles that go from the very basics to intermediate topics. Each article builds on what you learned in the previous one, so we recommend following them in order.

What is Python and why should you learn it?

Python is a programming language — a way to give instructions to your computer so it does what you want. Think of it as learning a new language, but instead of communicating with people, you communicate with your computer.

Python is one of the most popular languages in the world for several reasons:

  • Easy to read: Python code looks a lot like English, making it ideal for beginners
  • Versatile: You can use it to build websites, analyze data, create artificial intelligence, automate tasks, and much more
  • Huge community: Millions of people use Python, so you will always find help online
  • Free: Python is open source — you do not have to pay anything to use it
  • Great job market: Python is one of the most in-demand languages in the tech industry

To give you an idea of how simple Python is compared to other languages, here is a program that displays a message on screen:

python
1# Python - simple and clean
2print("Hello, World")

That is it. One single line. In other languages, you would need to write much more code to achieve the same thing.

Installation on Windows

Follow these steps to install Python on Windows:

Step 1: Download Python

  1. Open your browser and go to the official website: python.org/downloads
  2. Click the big yellow button that says "Download Python 3.x.x" (the latest version)
  3. An .exe file will be downloaded to your Downloads folder

Step 2: Run the installer

  1. Open the .exe file you just downloaded
  2. VERY IMPORTANT: Before clicking "Install Now", check the box that says "Add python.exe to PATH". This checkbox is at the bottom of the installer window
  3. Click "Install Now"
  4. Wait for the installation to finish (it may take 1-2 minutes)
  5. When you see the message "Setup was successful", click "Close"
⚠️ Important: If you forget to check the "Add python.exe to PATH" box, you will not be able to use Python from the terminal. If you already installed without checking it, uninstall Python and reinstall it with that box checked.

Installation on macOS

macOS comes with an older version of Python preinstalled, but we need to install the latest version.

Option 1: From the official website

  1. Go to python.org/downloads
  2. Download the macOS installer (.pkg file)
  3. Open the downloaded file and follow the installation wizard
  4. Click "Continue" on each step and then "Install"

Option 2: Using Homebrew (recommended for advanced users)

If you have Homebrew installed, simply open Terminal and type:

bash
1brew install python3

Installation on Linux

Most Linux distributions come with Python preinstalled. But if you need to install it or update it, use your distribution's package manager.

Ubuntu / Debian

bash
1# Update the package list
2sudo apt update
3
4# Install Python 3
5sudo apt install python3 python3-pip

Fedora

bash
1sudo dnf install python3 python3-pip

Arch Linux

bash
1sudo pacman -S python python-pip

Verify the installation

Now let's check that Python was installed correctly. To do this, we need to open a terminal (also called "command line"):

  • Windows: Press the Windows key, type cmd, and press Enter
  • macOS: Open the "Terminal" application (it is in Applications > Utilities)
  • Linux: Open your favorite terminal (usually with Ctrl + Alt + T)

Type the following command and press Enter:

bash
1python --version

You should see something like:

bash
1Python 3.12.4

The exact number may vary, but the important thing is that it starts with 3. If you see an error or it says "Python 2.x", try:

bash
1python3 --version
💡 Tip: On macOS and Linux, the command is sometimes python3 instead of python. If python does not work, use python3 instead.

Your first program: Hello World

It is a tradition in programming that the first program you write displays the message "Hello World" on screen. Let's do it!

Step 1: Create a folder for your files

Create a folder on your computer called python-course. You can create it on your desktop or wherever you prefer. We will store all the course files here.

Step 2: Create the file

Open any text editor (for now, Notepad on Windows or TextEdit on macOS works fine) and type the following:

python
1print("Hello, World!")

Save the file inside your python-course folder with the name hello.py. The .py extension tells the computer that it is a Python file.

Step 3: Run the program

Open the terminal, navigate to your folder, and run the file:

bash
1# Navigate to the folder (adjust the path based on where you created it)
2cd Desktop/python-course
3
4# Run the program
5python hello.py

You should see in the terminal:

bash
1Hello, World!

Congratulations! You just wrote and ran your first Python program. The print() function displays on screen whatever you put between the parentheses and quotes.

Try changing the message:

python
1print("My name is Alex and I am learning Python")
2print("2 + 2 =", 2 + 2)
3print("Python is awesome!")

Run it again and you will see three lines in the terminal. Each print() outputs a new line.

The interactive interpreter (REPL)

Python has a very useful tool called the REPL (Read-Eval-Print Loop). It is a kind of "conversation mode" where you type code and Python responds immediately, line by line.

To open the REPL, type in your terminal:

bash
1python

You will see something like this:

bash
1Python 3.12.4 (main, Jun  8 2024, 18:29:57)
2Type "help", "copyright", "credits" or "license" for more information.
3>>>

The three symbols >>> indicate that Python is waiting for your instruction. Try typing:

python
1>>> print("Hello from the REPL")
2Hello from the REPL
3
4>>> 5 + 3
58
6
7>>> "Python" * 3
8'PythonPythonPython'
9
10>>> 100 / 7
1114.285714285714286

The REPL is perfect for experimenting. When you want to try something quickly, you do not need to create a file — just open the REPL, type your code, and see the result instantly.

To exit the REPL, type:

python
1>>> exit()
💡 Tip: Use the REPL as your "programmer's calculator". Whenever you have a question about how something works in Python, open the REPL and try it. It is the fastest way to learn.

Install a code editor: Visual Studio Code

While you can write code in Notepad, it is much better to use a code editor. A code editor is like Notepad but with superpowers: it highlights your code with colors, warns you about errors, and helps you type faster.

The editor we recommend is Visual Studio Code (VS Code). It is free, lightweight, and very popular.

Step 1: Download VS Code

  1. Go to code.visualstudio.com
  2. Download the version for your operating system
  3. Install it following the installer instructions

Step 2: Install the Python extension

  1. Open VS Code
  2. Click the extensions icon in the left sidebar (it looks like a square with puzzle pieces)
  3. In the search bar, type "Python"
  4. Install the extension called "Python" by Microsoft (it is the first result, with millions of downloads)

Step 3: Open your project folder

  1. In VS Code, go to File > Open Folder
  2. Select your python-course folder
  3. Now you can see and edit all your files from VS Code

To create a new file, right-click in the file explorer on the left and select "New File". Name the file with a .py extension and start writing code.

Step 4: Run code from VS Code

With the Python extension installed, you can run your code directly from VS Code:

  1. Open a .py file
  2. Click the "play" button (triangle icon) that appears in the top-right corner
  3. A terminal will open inside VS Code showing the result
📌 Note: VS Code is just a recommendation. If you prefer another editor like PyCharm, Sublime Text, or even Vim, any of them will work. The important thing is that you feel comfortable with your tool.

Summary and next article

In this first article of the course, we accomplished the following:

  • Understood what Python is and why it is an excellent language to start programming
  • Installed Python on Windows, macOS, or Linux
  • Verified the installation using the terminal
  • Wrote and ran our first program: Hello World
  • Learned about the REPL for experimenting with code interactively
  • Installed and configured VS Code as our code editor

You now have everything you need to start programming. In the next article (Part 2 of 10), we will learn about variables and data types — the fundamental building blocks of any program. You will learn how to store information, work with numbers and text, and build your first calculator.

See you in the next article!

Share:
CV

Cristhian Villegas

Software Engineer specializing in Java, Spring Boot, Angular & AWS. Building scalable distributed systems with clean architecture.

Comments

Sign in to leave a comment

No comments yet. Be the first!

Related Articles