리소스
- Overview
- 빠른 시작
- Claude 3 모델 카드
- Claude 3.7 시스템 카드
- 시스템 상태
- Anthropic 코스
- 프롬프트 라이브러리
- 프롬프트 라이브러리
- 우주의 키스트로크
- 기업 선견자
- 웹사이트 마법사
- 엑셀 수식 전문가
- Google 앱스 스크립트 작성자
- Python 버그 버스터
- 시간 여행 컨설턴트
- 스토리텔링 조력자
- 출처 인용하기
- SQL 마법사
- 꿈 해석가
- 말장난꾼
- 요리 크리에이터
- 혼성어 시인
- 유머러스한 도우미 할(Hal)
- LaTeX 전문가
- 감정 색상화
- Git 마스터하기
- 비유의 달인
- 윤리적 딜레마 내비게이터
- 회의 기록자
- 관용구 해설가
- 코드 컨설턴트
- 함수 제작기
- 신조어 창작자
- CSV 변환기
- 이모지 인코더
- 문장 개선기
- 관점 분석기
- 퀴즈 생성기
- 마음챙김 멘토
- 초등학교 2학년 수준 단순화기
- VR 피트니스 혁신가
- PII 정화기
- 메모 마에스트로
- 커리어 코치
- 채점 전문가
- 혀 꼬부리기
- 면접 질문 작성기
- 문법 지니
- 수수께끼를 내겠습니다
- 코드 명확화 도구
- 외계 인류학자
- 데이터 정리기
- 브랜드 빌더
- 효율성 추정기
- 리뷰 분류기
- 방향 디코더
- 동기부여 뮤즈
- 이메일 추출기
- 마스터 중재자
- 수업 계획 작성기
- 소크라테스식 현자
- 두운법 연금술사
- 미래적 패션 어드바이저
- 다국어 초능력
- 제품 이름 짓기 전문가
- 철학적 사색
- 스프레드시트 마법사
- 공상과학 시나리오 시뮬레이터
- 적응형 에디터
- 바벨의 방송
- 트윗 톤 감지기
- 공항 코드 분석기
프롬프트 라이브러리
Python 버그 버스터
Python 코드의 버그를 감지하고 수정합니다.
직접 시도해보려면 이 프롬프트를 개발자 콘솔에 복사하세요!
Content | |
---|---|
System | 당신의 임무는 제공된 Python 코드 스니펫을 분석하여 존재하는 버그나 오류를 식별하고, 이러한 문제를 해결하는 수정된 코드 버전을 제공하는 것입니다. 원본 코드에서 발견한 문제점과 수정 사항이 어떻게 이를 해결하는지 설명하세요. 수정된 코드는 기능적이고 효율적이며 Python 프로그래밍의 모범 사례를 준수해야 합니다. |
User | def calculate_average(nums): sum = 0 for num in nums: sum += num average = sum / len(nums) return average numbers = [10, 20, 30, 40, 50] result = calculate_average(numbers) print(“The average is:”, results) |
예시 출력
수정된 Python 코드:
Python
def calculate_average(nums):
total = 0
for num in nums:
total += num
average = total / len(nums)
return average
numbers = [10, 20, 30, 40, 50]
result = calculate_average(numbers)
print("The average is:", result)
설명:
- 내장 Python 함수 “sum()“과의 충돌을 피하기 위해 변수 이름 “sum”을 “total”로 변경했습니다.
- print 문에서 오타를 수정하여 “results”를 “result”로 변경하여 변수를 올바르게 참조하도록 했습니다.
API 요청
import anthropic
client = anthropic.Anthropic(
# defaults to os.environ.get("ANTHROPIC_API_KEY")
api_key="my_api_key",
)
message = client.messages.create(
model="claude-opus-4-20250514",
max_tokens=1000,
temperature=0,
system="Your task is to analyze the provided Python code snippet, identify any bugs or errors present, and provide a corrected version of the code that resolves these issues. Explain the problems you found in the original code and how your fixes address them. The corrected code should be functional, efficient, and adhere to best practices in Python programming.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "def calculate_average(nums):\n sum = 0\n for num in nums:\n sum += num\n average = sum / len(nums)\n return average\n\nnumbers = [10, 20, 30, 40, 50]\nresult = calculate_average(numbers)\nprint(\"The average is:\", results)"
}
]
}
]
)
print(message.content)
import anthropic
client = anthropic.Anthropic(
# defaults to os.environ.get("ANTHROPIC_API_KEY")
api_key="my_api_key",
)
message = client.messages.create(
model="claude-opus-4-20250514",
max_tokens=1000,
temperature=0,
system="Your task is to analyze the provided Python code snippet, identify any bugs or errors present, and provide a corrected version of the code that resolves these issues. Explain the problems you found in the original code and how your fixes address them. The corrected code should be functional, efficient, and adhere to best practices in Python programming.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "def calculate_average(nums):\n sum = 0\n for num in nums:\n sum += num\n average = sum / len(nums)\n return average\n\nnumbers = [10, 20, 30, 40, 50]\nresult = calculate_average(numbers)\nprint(\"The average is:\", results)"
}
]
}
]
)
print(message.content)
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic({
apiKey: "my_api_key", // defaults to process.env["ANTHROPIC_API_KEY"]
});
const msg = await anthropic.messages.create({
model: "claude-opus-4-20250514",
max_tokens: 1000,
temperature: 0,
system: "Your task is to analyze the provided Python code snippet, identify any bugs or errors present, and provide a corrected version of the code that resolves these issues. Explain the problems you found in the original code and how your fixes address them. The corrected code should be functional, efficient, and adhere to best practices in Python programming.",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "def calculate_average(nums):\n sum = 0\n for num in nums:\n sum += num\n average = sum / len(nums)\n return average\n\nnumbers = [10, 20, 30, 40, 50]\nresult = calculate_average(numbers)\nprint(\"The average is:\", results)"
}
]
}
]
});
console.log(msg);
from anthropic import AnthropicBedrock
# See https://docs.anthropic.com/claude/reference/claude-on-amazon-bedrock
# for authentication options
client = AnthropicBedrock()
message = client.messages.create(
model="anthropic.claude-opus-4-20250514-v1:0",
max_tokens=1000,
temperature=0,
system="Your task is to analyze the provided Python code snippet, identify any bugs or errors present, and provide a corrected version of the code that resolves these issues. Explain the problems you found in the original code and how your fixes address them. The corrected code should be functional, efficient, and adhere to best practices in Python programming.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "def calculate_average(nums):\n sum = 0\n for num in nums:\n sum += num\n average = sum / len(nums)\n return average\n\nnumbers = [10, 20, 30, 40, 50]\nresult = calculate_average(numbers)\nprint(\"The average is:\", results)"
}
]
}
]
)
print(message.content)
import AnthropicBedrock from "@anthropic-ai/bedrock-sdk";
// See https://docs.anthropic.com/claude/reference/claude-on-amazon-bedrock
// for authentication options
const client = new AnthropicBedrock();
const msg = await client.messages.create({
model: "anthropic.claude-opus-4-20250514-v1:0",
max_tokens: 1000,
temperature: 0,
system: "Your task is to analyze the provided Python code snippet, identify any bugs or errors present, and provide a corrected version of the code that resolves these issues. Explain the problems you found in the original code and how your fixes address them. The corrected code should be functional, efficient, and adhere to best practices in Python programming.",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "def calculate_average(nums):\n sum = 0\n for num in nums:\n sum += num\n average = sum / len(nums)\n return average\n\nnumbers = [10, 20, 30, 40, 50]\nresult = calculate_average(numbers)\nprint(\"The average is:\", results)"
}
]
}
]
});
console.log(msg);
from anthropic import AnthropicVertex
client = AnthropicVertex()
message = client.messages.create(
model="claude-3-7-sonnet-v1@20250219",
max_tokens=1000,
temperature=0,
system="Your task is to analyze the provided Python code snippet, identify any bugs or errors present, and provide a corrected version of the code that resolves these issues. Explain the problems you found in the original code and how your fixes address them. The corrected code should be functional, efficient, and adhere to best practices in Python programming.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "def calculate_average(nums):\n sum = 0\n for num in nums:\n sum += num\n average = sum / len(nums)\n return average\n\nnumbers = [10, 20, 30, 40, 50]\nresult = calculate_average(numbers)\nprint(\"The average is:\", results)"
}
]
}
]
)
print(message.content)
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
// Reads from the `CLOUD_ML_REGION` & `ANTHROPIC_VERTEX_PROJECT_ID` environment variables.
// Additionally goes through the standard `google-auth-library` flow.
const client = new AnthropicVertex();
const msg = await client.messages.create({
model: "claude-3-7-sonnet-v1@20250219",
max_tokens: 1000,
temperature: 0,
system: "Your task is to analyze the provided Python code snippet, identify any bugs or errors present, and provide a corrected version of the code that resolves these issues. Explain the problems you found in the original code and how your fixes address them. The corrected code should be functional, efficient, and adhere to best practices in Python programming.",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "def calculate_average(nums):\n sum = 0\n for num in nums:\n sum += num\n average = sum / len(nums)\n return average\n\nnumbers = [10, 20, 30, 40, 50]\nresult = calculate_average(numbers)\nprint(\"The average is:\", results)"
}
]
}
]
});
console.log(msg);
Was this page helpful?