미들
2026년 10월 4일

버그를 찾아라: Django

코드 한 조각. 버그를 찾거나, 버그가 없음을 증명하세요.

python
1from django.core.cache import cache
2from .models import Product
3
4def get_product_price(product_id, discount_codes=[]):
5    product = Product.objects.get(pk=product_id)
6    price = product.price
7    if product.on_sale:
8        discount_codes.append('AUTO_SALE')
9    for code in discount_codes:
10        price = apply_discount(price, code)
11    return price
12
13def apply_discount(price, code):
14    rate = cache.get(f'discount:{code}', 0)
15    return price * (1 - rate)

문제가 되는 줄을 클릭하세요.

당신의 판단

하루 한 번. 제출하면 바로 정답이 표시됩니다.

연속 기록 유지하기

계정을 만들면 연속 기록을 유지하고 진행 상황을 추적할 수 있습니다.

계정 만들기