Advertisement
Korotkodul

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

Feb 22nd, 2025 (edited)
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 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.     sold_per_month = np.sum(amounts_of_sold_subscriptions, axis = 1)
  15.     print("sold_per_month")
  16.     print(sold_per_month)
  17.     indices = np.argsort(sold_per_month)
  18.     print("indices")
  19.     print(indices)
  20.     return months_list[indices[11]]
  21.  
  22. array = np.random.randint(-10, 10, size=(12, 3))
  23. price = np.random.randint(1, 10, size=(1, 3))
  24. print("array")
  25. print(array)
  26.  
  27. k = get_most_profitable_month_name(array, price)
  28. print("k", k)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement