Bekerja dengan DeepSeek di Python
James Chapman
AI Curriculum Lead, DataCamp
print(response.choices[0].message.content)
Langkah 1 - ...
Langkah 2 - ...
Jawaban Akhir: ...
reasoning_effort="high" atau "max"temperature tidak berpengaruh saat penalaran✅ 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."
❌ Pemakaian token meningkat
❌ Waktu respons lebih lama


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)
Mari hitung langkah demi langkah.
- Mulai dari 1.
- Tambah 1 lagi.
- 1 + 1 = 2.
**Jawaban Akhir: 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)
Saya akan menelusuri fungsi ini langkah demi langkah.
Fungsi menggunakan while loop: while start < 10. Lalu mencetak start. Namun, di dalam loop,
tidak ada penambahan pada variabel start — inilah masalahnya.
Perbaikannya adalah menambahkan increment pada start di dalam loop, misalnya start += 1.
Berikut kode yang sudah diperbaiki:
def count_to_ten(start):
while start < 10:
print(start)
start += 1
return "Done"
count_to_ten(1)
Bekerja dengan DeepSeek di Python