Variance from budget
A ledger compares what was planned against what actually happened: report the signed difference.
- Variance is actual minus budget.
- The result keeps its sign — overspend is positive, underspend negative.
budget_variance(budget: int, actual: int) → int
Where you start
def budget_variance(budget: int, actual: int) -> int:
Worked examples
| Call | Result |
|---|---|
budget_variance(100, 120) | 20 |
budget_variance(100, 90) | -10 |
budget_variance(0, 0) | 0 |
budget_variance(50, 50) | 0 |
Hint
Subtract budget from actual.
Reference solution in Python
def budget_variance(budget: int, actual: int) -> int:
return actual - budget