🛠️ToolsShed

할인 계산기

세일 가격, 할인 금액, 절약액을 즉시 계산.

할인 계산기는 백분율 할인이 적용된 후 판매 가격을 즉시 계산하거나, 원래 가격과 판매 가격이 주어졌을 때 받고 있는 할인율을 알려줍니다. 거래를 평가하는 쇼핑객, 프로모션 가격을 설정하는 소매업체, 다른 매장에서 제안을 비교하는 누구에게나 유용합니다.

원래 가격과 할인율을 입력하면 절약 금액과 최종 가격이 표시됩니다. 또는 원래 가격과 판매 가격을 입력하면 절약 비율을 계산합니다. 첫 번째 할인 위에 두 번째 할인을 적용해야 하는 경우 여러 할인 쌓기도 처리합니다.

20% 할인이 가격이 원래의 20%라는 의미가 아닙니다 — 80%를 지불한다는 의미입니다. 이 차이는 할인을 쌓을 때 중요합니다: 두 개의 20% 할인은 60%가 아닌 원래 가격의 64%(0.8 × 0.8 = 0.64)를 지불하는 결과를 낳습니다.

자주 묻는 질문

코드 구현

def calculate_discount(original_price, discount_percent):
    """Calculate discounted price and savings."""
    discount_amount = original_price * (discount_percent / 100)
    final_price = original_price - discount_amount
    return {
        "original": original_price,
        "discount_amount": round(discount_amount, 2),
        "final_price": round(final_price, 2),
        "savings_percent": discount_percent,
    }

def calculate_discount_percent(original_price, sale_price):
    """Find the discount percentage from two prices."""
    return round(((original_price - sale_price) / original_price) * 100, 2)

def stack_discounts(original_price, *discounts):
    """Apply multiple discounts sequentially."""
    price = original_price
    for d in discounts:
        price *= (1 - d / 100)
    return round(price, 2)

# Examples
print(calculate_discount(80, 30))
print(calculate_discount_percent(50, 35))  # => 30.0%
print(stack_discounts(100, 20, 10))         # => 72.0 (not 70.0)

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.