# Possibility of firm bankruptcy

```# Based on the book "Python for finance", second edition def possibility_of_firm_bankruptcy(ebit, net_sales, market_value_of_equity, working_capital, retained_earnings, total_assets, total_liabilities): """ Based on Altman z-score EBIT: earnings before interest and taxes """ z_score = (3.3*ebit + 0.99*net_sales + 1.2*working_capital + 1.4*retained_earnings) / total_assets + (0.6*market_value_of_equity) / total_liabilities return z_score def show_feedback(z_score): msg = '' if z_score < 1.8: msg = 'Probability of financial distress is very high' elif 1.8 < z_score < 2.7: msg = 'Good chances of going bankrupt within two years' elif 2.7 < z_score < 2.9: msg = 'On alert' elif z_score > 3.0: msg = 'Safe' return msg # Annual report (values in million dollars) company = 'Berkshire Hathaway' year = 2017 # Note: There is no guarantee about the numbers you see here ebit = 44353 net_sales = 242137 stock_price = 297.60 shares_outstanding = 747.68 * 1000 market_value_of_equity = stock_price * shares_outstanding # ? retained_earnings = 255786 total_assets = 702095 total_liabilities = 350141 working_capital = total_assets - total_liabilities # ? z_score = possibility_of_firm_bankruptcy(ebit, net_sales, market_value_of_equity, working_capital, retained_earnings, total_assets, total_liabilities) print('%s, %s -> z-score: %.4f -> %s' % (company, year, round(z_score, 4), show_feedback(z_score))) # Berkshire Hathaway, 2017 -> z-score: 382.9529 -> Safe ```