Advertisement
Korotkodul

A. Часть 1. Самый прибыльный месяц

Feb 23rd, 2025 (edited)
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import numpy as np
  2. import calendar
  3. months_list = [calendar.month_name[i] for i in range(1, 13)]
  4.  
  5. class InconsistentDataError(Exception):
  6.     pass
  7.  
  8. def get_most_profitable_month_name(
  9.     amounts_of_sold_subscriptions: np.ndarray,
  10.     subscriptions_prices: np.ndarray,
  11. ) -> str:
  12.     if amounts_of_sold_subscriptions.shape[1] != subscriptions_prices.shape[1]:
  13.         raise InconsistentDataError
  14.     income = amounts_of_sold_subscriptions * subscriptions_prices
  15.     sold_per_month = np.sum(income, axis = 1)
  16.     max_id = np.argmax(sold_per_month)
  17.     return months_list[max_id]
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement