Python introduction

Ludovic Deneuville

History

  • Created by Guido van Rossum (Netherlands)
  • First version in 1991
  • Managed by the Python Software Foundation since 2001
  • Python 3.13: python --version

Why Learn Python?

  • Versatile and popular language
  • Easy to learn and read
  • Large community and many resources
  • Many packages

Python Fundamentals

  • Interpreted and interactive language
  • Dynamic typing
  • Clear and concise syntax
  • Supports several paradigms (procedural, object-oriented, functional)

Python at ENSAI

Packages

In a terminal (for example: Git Bash)


pip list                            # Installed packages
pip install <package>               # Install a package
pip install <package>==<version>    # Specific version
pip uninstall <package>

# Distribution used

python -c 'import platform; print(platform.python_implementation())'

Writing Your First Python Code

  • Variables and data types (int, float, str, bool, list, dict)
  • Basic operations
  • Sensitive to indentation
  • Control structures (if, for, while)

Control Structures

Collections - the 2 main ones

  • List: ordered collection of modifiable values

list = ["apple", "pear", 2, True]
  • Dictionary: unordered collection of key-value pairs

recipe = {"strawberry": 5, "Mustard": "5g"}

Other Useful Collections

  • Set: unordered collection of unique values

primes = {2, 3, 5, 7, 11, 13}
  • Tuple: ordered collection of immutable values

coord = (-1, 5, 4)

Note

Many other collection types exist (Tree, Linked List…).

Main Collections - Summary

Data Type Ordered Mutable Duplicate
list
dict
tuple
set

Development Assistance

To learn the language, avoid rushing to LLMs.

Prefer:

Useful Resources

At Work

5 notebooks are available to help you learn the basics of the language:

How to use notebooks