Working with DeepSeek in Python
James Chapman
Curriculum Manager, DataCamp
<think>
Thought process...
</think>
Final response: ...
model="deepseek-ai/DeepSeek-R1"
temperature
parameter for reasoning models✅ 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."
✅ Improved accuracy
❌ Increased token usage
❌ Increased time-to-response
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1",
messages=[{"role": "user", "content": "Return the result of 1+1."}]
)
<think>
Okay, so the user is asking for the result of 1 plus 1. Let me think about this. Well, basic
arithmetic tells me that when you add two numbers together, you combine their values. So 1 added
to another 1 should be... hmm. Let me visualize it. If I have one apple and someone gives me
another apple, I now have two apples. That makes sense. So 1 + 1 equals 2. Wait, is there any
trick here? The question seems straightforward, but maybe I should double-check. Let me count on
my fingers. One finger up, then add another...
</think>
The result of 1 + 1 is **2**.
Chat output
The result of \(1 + 1\) is \(2\).
\[
1 + 1 = 2
\]
prompt = """
[Task: Fix the following code.]
Code:
def count_to_ten(start):
while start < 10:
print(start)
return "Done"
count_to_ten(1)
"""
<think>
Okay, let's see. The user provided a Python function called count_to_ten...
The function uses a while loop: while start < 10. Then it prints start. But wait, inside the loop,
there's no increment for the start variable. Oh right, that's the issue...
So the fix is to add an increment to start inside the loop. Like start += 1...
</think>
Here is the corrected code:
def count_to_ten(start):
while start < 10:
print(start)
start += 1
return "Done"
count_to_ten(1)
Working with DeepSeek in Python