An introduction in the form of a webinar, to allow you to discover the importance of the Python language as a programming tool for your company’s internal needs or for the development of an application. This introduction focuses on presenting the basic concepts needed to get you started, such as the use of the Python interpreter and the syntax elements you need for a first program.
1. Introduction to Python
a. What is Python ?
An “interpreted” programming language : instructions are transformed into a machine language and executed as they are read.
Open source software (since about 1990).
Official website: Python.org https://python.org
Python can be used for almost any purpose:
Web and mobile applications,
Data science (analytics, machine learning, computer vision…)
b. Installer Python
- Recommended to use version 3 (3.6, 3.7, 3.8).
- Windows: Download and install the executable.
- Mac: Install with Homebrew
- Linux :
- Debian / Ubuntu
- Debian / Ubuntu
2. Discover Python with the interpreter
Assuming Python is installed, you can run the interpreter to start working.
You get the interpreter window, which is also called the “Python Shell”, and can be recognized by its command prompt
To exit the interpreter, use the
quit() statement or do
Ctrl-C depending on the operating system)
a. Notes on functions
In the above,
quit is an example of what we call a function.
Functions are available in the Python language and are used to do processing and possibly return values.
We will see more examples of functions later on.
b. How to display values
This function is able to display on the screen (the console of the interpreter) one or more values (or values resulting from operations).
To display a number :
To display multiple values :
c. How to enter values
We use the
Allows you to offer a “value input prompt”.
This allows the user of our program to enter information (data) that will be used within the program.
To display this name :
d. How to get help
We use the
For example, to display the documentation for the
Let’s look at some basic concepts: Variables, Code Indentation, Conditions, Loops.
Variables help perform operations.
A variable is declared by giving it a value (the assignment of a value to the variable).
The assignment is made using the =, called the assignment operator.
Autres exemples :
b. The indentation of the code
In Python, indenting your code is mandatory: you shift (to the right) with 4 spaces.
There will be syntax errors if the code is badly indented.
c. Conditions (if / else)
Several variants are possible in the syntax, depending on the number of conditions.
Syntax for 1 condition :
Syntax for 1 condition + its opposite :
Syntax for several alternative conditions
A little example
d. The loops
There are 2 types of loops :
For this initiation, we only deal with the first type.
With the “for loop“, we loop on a list or a sequence of elements.
Example showing a loop :