Working with DeepSeek in Python
James Chapman
AI Curriculum Lead, DataCamp
![]()
![]()
A train travels 60 miles in 1.5 hours. If it continues at the same speed, how far will it travel in 4 hours, and what time will it arrive if it leaves at 2:15 PM?

A train travels 60 miles in 1.5 hours. If it continues at the same speed, how far will it travel in 4 hours, and what time will it arrive if it leaves at 2:15 PM?
Calculate the speed (60 ÷ 1.5 = 40 mph)
Multiply by 4 hours to find the distance (40 × 4 = 160 miles)
Add 4 hours to the departure time (2:15 PM + 4 hours = 6:15 PM)
Return: "160 miles, arrival at 6:15 PM"

response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role": "user", "content": train_problem}]
)
print(response.choices[0].message.content)
print(response.choices[0].message.content)
**Step 1 - Find the train's speed**
Speed = 60 / 1.5 = **40 mph**
**Step 2 - Distance in 4 hours**
Distance = 40 × 4 = **160 miles**
**Step 3 - Arrival time**
2:15 PM + 4 hours = **6:15 PM**
**Final Answer:** 160 miles, arriving at 6:15 PM
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
extra_body={"thinking": {"type": "disabled"}},
messages=[{"role": "user", "content": prompt}]
)
"enabled" by default; pass "disabled" to opt outresponse = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
reasoning_effort="max",
messages=[{"role": "user", "content": train_problem}]
)
print(response.choices[0].message.content)
"high" → set to "max" for tougher problemsWorking with DeepSeek in Python