C'est quoi Python ?
Python est un langage de programmation universel. Contrairement à HTML, CSS ou JavaScript qui vivent dans le navigateur, Python tourne sur votre ordinateur, sur un serveur, dans le cloud — partout.
Il est utilisé pour tout :
- Sites web — Django, Flask, FastAPI
- Data science — Pandas, NumPy, Matplotlib
- Intelligence artificielle — TensorFlow, PyTorch
- Automatisation — scripts, web scraping, bots
Sa force ? Une syntaxe lisible, proche de l'anglais. Là où d'autres langages utilisent des accolades {} et des points-virgules ;, Python utilise l'indentation — des espaces en début de ligne.
Pourquoi apprendre Python avec l'IA ?
L'IA génère du Python en quelques secondes. Mais quand le script plante à la ligne 42 avec un IndentationError, il faut comprendre pourquoi.
Avec ces 6 leçons, vous allez apprendre à :
- Lire du Python et comprendre ce qu'il fait
- Modifier le code généré par l'IA pour l'adapter
- Débugger quand un script ne marche pas
print() — votre premier Python
print() est la commande la plus utile en Python. Elle affiche un message dans le terminal.
print("Bonjour le monde")
Résultat dans le terminal :
Bonjour le monde
Pas de point-virgule, pas d'accolades. Juste print() et des parenthèses. C'est cette simplicité qui fait la force de Python.
Commentaires et indentation
Les commentaires commencent par # — Python les ignore :
# Ceci est un commentaire
print("Bonjour") # commentaire en fin de ligne
L'indentation (4 espaces) est obligatoire en Python. Elle définit les blocs de code :
age = 18
if age >= 18:
print("Vous êtes majeur") # indenté = dans le bloc if
print("Bienvenue !") # même bloc
print("Fin du programme") # pas indenté = en dehors du if
Résultat :
Vous êtes majeur
Bienvenue !
Fin du programme
Attention : mélanger tabulations et espaces provoque une erreur. Utilisez toujours 4 espaces.
Variables sans déclaration de type
En Python, pas besoin de let, const ou var. On écrit directement :
nom = "Alice"
age = 25
taille = 1.68
est_etudiant = True
print(nom) # Alice
print(age) # 25
print(est_etudiant) # True
Python devine le type automatiquement. On appelle ça le typage dynamique.
What is Python?
Python is a universal programming language. Unlike HTML, CSS, or JavaScript that live in the browser, Python runs on your computer, on a server, in the cloud — everywhere.
It's used for everything:
- Websites — Django, Flask, FastAPI
- Data science — Pandas, NumPy, Matplotlib
- Artificial intelligence — TensorFlow, PyTorch
- Automation — scripts, web scraping, bots
Its strength? A readable syntax, close to English. Where other languages use curly braces {} and semicolons ;, Python uses indentation — spaces at the beginning of lines.
Why learn Python with AI?
AI generates Python in seconds. But when the script crashes at line 42 with an IndentationError, you need to understand why.
In these 6 lessons, you'll learn to:
- Read Python and understand what it does
- Modify AI-generated code to fit your needs
- Debug when a script doesn't work
print() — your first Python
print() is the most useful command in Python. It displays a message in the terminal.
print("Hello world")
Result in the terminal:
Hello world
No semicolons, no curly braces. Just print() and parentheses. This simplicity is Python's strength.
Comments and indentation
Comments start with # — Python ignores them:
# This is a comment
print("Hello") # end-of-line comment
Indentation (4 spaces) is mandatory in Python. It defines code blocks:
age = 18
if age >= 18:
print("You are an adult") # indented = inside the if block
print("Welcome!") # same block
print("End of program") # not indented = outside the if
Result:
You are an adult
Welcome!
End of program
Warning: mixing tabs and spaces causes an error. Always use 4 spaces.
Variables without type declaration
In Python, no need for let, const, or var. Just write directly:
name = "Alice"
age = 25
height = 1.68
is_student = True
print(name) # Alice
print(age) # 25
print(is_student) # True
Python figures out the type automatically. This is called dynamic typing.
Copiez ce prompt dans Claude ou ChatGPT :
Explique-moi les différences entre Python et JavaScript en 5 points. Pour chaque différence, montre un exemple de code dans les deux langages.