在 Python 中使用 DeepSeek
James Chapman
AI Curriculum Lead, DataCamp
print(response.choices[0].message.content)
Step 1 - ...
Step 2 - ...
Final Answer: ...
reasoning_effort="high" 或 "max" 调整temperature 无任何作用✅ 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."
❌ token 使用增加
❌ 响应时间更长


response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role": "user", "content": "Return the result of 1+1."}]
)
print(response.choices[0].message.content)
让我们逐步计算。
- 从 1 开始。
- 再加 1。
- 1 + 1 = 2。
**最终答案: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)
让我逐步分析该函数。
该函数使用 while 循环:while start < 10,然后打印 start。但循环内
没有对 start 递增——这就是问题。
修复方法是在循环中给 start 递增,例如 start += 1。
修正后的代码:
def count_to_ten(start):
while start < 10:
print(start)
start += 1
return "Done"
count_to_ten(1)
在 Python 中使用 DeepSeek