Bekerja dengan DeepSeek di Python
James Chapman
Curriculum Manager, DataCamp
<think>
Proses berpikir...
</think>
Respons akhir: ...
model="deepseek-ai/DeepSeek-R1"temperature untuk model 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."
✅ Akurasi meningkat
❌ Penggunaan token meningkat
❌ Waktu respons lebih lama


response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1",
messages=[{"role": "user", "content": "Return the result of 1+1."}]
)
<think>
Baik, pengguna meminta hasil dari 1 tambah 1. Pikirkan sebentar. Aritmetika dasar: menambah dua
angka berarti menjumlahkan nilainya. Jadi 1 ditambah 1 seharusnya... hmm. Bayangkan: satu apel,
ditambah satu apel lagi, jadi dua apel. Masuk akal. Jadi 1 + 1 = 2. Ada trik? Sepertinya tidak,
namun saya cek lagi. Hitung dengan jari: satu, tambah satu...
</think>
Hasil 1 + 1 adalah **2**.
Keluaran chat
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>
Baik, mari lihat. Pengguna memberi fungsi Python bernama count_to_ten...
Fungsi memakai while: while start < 10. Lalu mencetak start. Namun, di dalam loop,
tidak ada penambahan nilai start. Benar, itu masalahnya...
Perbaikannya: tambah increment pada start di dalam loop, mis. start += 1...
</think>
Berikut kode yang diperbaiki:
def count_to_ten(start):
while start < 10:
print(start)
start += 1
return "Done"
count_to_ten(1)
Bekerja dengan DeepSeek di Python