Accueil Blog Projets CV Contact

Cet article n'est pas encore disponible en français. Vous lisez la version anglaise.

How to Install Python and Write Your First Program (Mac, Windows, Linux)

Sidali Assoul Sidali Assoul 2 min de lecture

Dernière mise à jour le

Introduction

Python is one of the most known programming languages, it powers everthing from web applications and data science models to simple automation scripts.

It’s also one of the easiest languages to learn because of its english like syntax, dynamic typing and abstractions.

In this quick guide, we will walk through the steps needed to install Python on Windows, macOS, and Linux, configure your system, and execute your very first script. Let’s dive right in.

Installation

First of all you have to install python on your machine.

Depending on your operating system the steps may differ. But in MacOs and linux it’s just a matter of running a single command.

MacOS and Linux

brew install python # MacOs

sudo apt install python3-full # Linux

Windows

Add to PATH Python Windows On windows, just head to the python.org website, dowonload the corresponding binary, and make sure to check the “Add to PATH” option.

To confirm that it’s indeed installed, restart your terminal app, and then run:

python3 --version # or python --version

If a version number appears, then Python is succesfully installed on your system.

Python Install For Each OS

First Program: Hello World!

Let’s create our first Python program.

First, we need to create a “hello.py” file, open it with your preferred IDE, and then write a simple “print” statement that just prints “Hello, World!” to the console (the default standard output or “stdout”).

print("Hello, World!")

Now, let’s run out the previously created program by typing:

python3 hello.py # Or python

And then press on enter.

As expected a hello world gets printed on your console.

Output:

Hello, World!

You can also use Python’s interactive mode where any code you type executes line by line, by running the previous python3 command without any arguments.

python3  

Hello World Interactive Mode Python

Summary

Installation

# macOS
brew install python

# Ubuntu/Debian
sudo apt install python3-full

# Verify the installation
python3 --version

Your first program

print("Hello, World!")
python3 hello.py

Interactive mode

python3

Key Notes for Interviews

  • Python programs are plain .py files executed with python3 filename.py.
  • print() writes text to the console (default stdout).
  • Running python3 without a filename starts the interactive Python shell (REPL), where code executes immediately, which is pretty handy when you want to quickly test stuff.

Conclusion

At this point, Python is succesfully installed on your system, and you wrote your first Python program!

In the next lesson, we’ll look at variables and data types, which are crucial to understand as they form the backbone of every Python program.

Continue to the next chapter, and we’ll build on what you’ve learned here.

Continue to Variables and Data Types

Cet article vous a plu ?

Je suis ouvert à de nouveaux postes, en télétravail ou à l'international. Si quelque chose vous a parlé ou si vous souhaitez collaborer, j'adorerais en discuter.

Se connecter sur LinkedIn
Sidali Assoul

Écrit par

Sidali Assoul

Ingénieur logiciel avec 5 ans d'expérience en développement web et mobile full stack, un bilan éprouvé en data science, recherche et solutions IA modernes, avec une approche orientée business pour livrer des produits à forte valeur ajoutée.