🛠️ToolsShed

Calculadora de Depreciação

Calcula a depreciação de ativos pelos métodos linear e saldo decrescente.

Perguntas Frequentes

Implementação de Código

def straight_line_depreciation(cost, salvage, life):
    """Straight-line depreciation."""
    annual = (cost - salvage) / life
    book_value = cost
    for year in range(1, life + 1):
        book_value -= annual
        print(f"Year {year}: depreciation={annual:.2f}, book value={book_value:.2f}")
    return annual

def declining_balance_depreciation(cost, salvage, life, rate=None):
    """Declining balance depreciation."""
    if rate is None:
        rate = 2 / life  # double-declining
    book_value = cost
    for year in range(1, life + 1):
        dep = min(book_value * rate, book_value - salvage)
        book_value -= dep
        print(f"Year {year}: depreciation={dep:.2f}, book value={book_value:.2f}")

# Example
straight_line_depreciation(cost=10000, salvage=1000, life=5)
declining_balance_depreciation(cost=10000, salvage=1000, life=5)

Comments & Feedback

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