Làm việc với DeepSeek trong Python
James Chapman
AI Curriculum Lead, DataCamp
print(response.choices[0].message.content)
Bước 1 - ...
Bước 2 - ...
Đáp án cuối: ...
reasoning_effort="high" hoặc "max"temperature không tác dụng khi reasoning✅ 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."
❌ Tăng số token sử dụng
❌ Tăng thời gian phản hồi


response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4.1-Flash",
messages=[{"role": "user", "content": "Return the result of 1+1."}]
)
print(response.choices[0].message.content)
Hãy tính từng bước.
- Bắt đầu với 1.
- Cộng thêm 1 nữa.
- 1 + 1 = 2.
**Đáp án cuối: 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)
Mình sẽ đi qua hàm này từng bước.
Hàm dùng vòng lặp while: while start < 10. Sau đó in start. Nhưng bên trong vòng lặp
không có bước tăng biến start — đây là vấn đề.
Cách sửa là tăng start trong vòng lặp, ví dụ start += 1.
Đây là mã đã sửa:
def count_to_ten(start):
while start < 10:
print(start)
start += 1
return "Done"
count_to_ten(1)
Làm việc với DeepSeek trong Python