Travailler avec DeepSeek en Python
James Chapman
AI Curriculum Lead, DataCamp
print(response.choices[0].message.content)
Étape 1 - ...
Étape 2 - ...
Réponse finale : ...
reasoning_effort="high" ou "max"temperature n'a aucun effet pendant le raisonnement✅ What are the differences between lists and tuples in Python?
❌ In Python, there are different data structures. Lists are...
✅ Who developed the Python programming language?
❌
Example 1:
Q: Who developed the R programming language?
A: Ross Ihaka and Robert Gentleman
"... Take your time and think through each step."
❌ Plus de jetons utilisés
❌ Délai de réponse accru


response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro-0813",
messages=[{"role": "user", "content": "Return the result of 1+1."}]
)
print(response.choices[0].message.content)
Comptons étape par étape.
- Commencer à 1.
- Ajouter un autre 1.
- 1 + 1 = 2.
**Réponse finale : 2**



prompt = """
[Task: Fix the following code.]
Code:
def count_to_ten(start):
while start < 10:
print(start)
return "Done"
count_to_ten(1)
"""
print(response.choices[0].message.content)
Passons en revue la fonction étape par étape.
La fonction utilise une boucle while : while start < 10. Puis elle affiche start. Mais attention : à l'intérieur de la boucle,
il n'y a pas d'incrément pour la variable start — c'est le problème.
La correction consiste à incrémenter start dans la boucle, par exemple start += 1.
Voici le code corrigé :
def count_to_ten(start):
while start < 10:
print(start)
start += 1
return "Done"
count_to_ten(1)
Travailler avec DeepSeek en Python