Advertisement
ALEXANDAR_GEORGIEV

report_system

Jun 8th, 2022 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1. need_sum = int(input())
  2. check_need_sum = need_sum
  3. check_cash = True
  4. cash_sum = []
  5. card_sum = []
  6.  
  7. while check_need_sum:
  8.     current_sum = input()
  9.     if current_sum == 'End':
  10.         break
  11.     current_sum = int(current_sum)
  12.     # Проверка за Възможна транзакция
  13.     if check_cash and current_sum <= 100:
  14.         print('Product sold!')
  15.         cash_sum.append(current_sum)
  16.         check_need_sum -= current_sum
  17.         check_cash = False
  18.         if check_need_sum < 0:
  19.             break
  20.     elif not check_cash and current_sum >= 10:
  21.         print('Product sold!')
  22.         card_sum.append(current_sum)
  23.         check_need_sum -= current_sum
  24.         check_cash = True
  25.         if check_need_sum < 0:
  26.             break
  27.     else:
  28.         print('Error in transaction!')
  29.         if check_cash:
  30.             check_cash = False
  31.         elif not check_cash:
  32.             check_cash = True
  33. if not len(card_sum):
  34.     aver_card = 0
  35. elif not len(cash_sum):
  36.     aver_cash = 0
  37. else:
  38.     aver_cash = sum(cash_sum) / len(cash_sum)
  39.     aver_card = sum(card_sum) / len(card_sum)
  40.  
  41. if current_sum == 'End':
  42.     print('Failed to collect required money for charity.')
  43. else:
  44.     print(f'Average CS: {aver_cash:.2f}')
  45.     print(f'Average CC: {aver_card:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement