비상금 계산기
월 지출과 권장 커버리지 개월 수를 기반으로 비상금 목표 금액을 계산합니다.
EmergencyFundCalculator.expensesTitle
$
$
$
$
$
EmergencyFundCalculator.totalMonthlyLabel$2,800/mo
$
EmergencyFundCalculator.targetLabel
$16,800
EmergencyFundCalculator.stillNeededLabel
$16,800
EmergencyFundCalculator.progressLabel0%
자주 묻는 질문
코드 구현
def emergency_fund_target(monthly_expenses, months=6):
"""Calculate the target emergency fund amount."""
return round(monthly_expenses * months, 2)
def months_to_goal(target, current_savings, monthly_contribution):
"""How many months to reach the emergency fund goal."""
if monthly_contribution <= 0:
return float("inf")
remaining = target - current_savings
if remaining <= 0:
return 0
return -(-remaining // monthly_contribution) # ceiling division
def progress_percent(current, target):
"""Percentage of goal reached."""
return min(round((current / target) * 100, 1), 100)
# Example: $3,500/mo expenses, 6-month target
target = emergency_fund_target(3500, 6) # 21000
print(f"Target: ${target:,.2f}")
print(f"Months to goal: {months_to_goal(target, 5000, 500)}") # 32
print(f"Progress: {progress_percent(5000, target)}%") # 23.8%Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.