Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- need_sum = int(input())
- check_need_sum = need_sum
- check_cash = True
- cash_sum = []
- card_sum = []
- while check_need_sum:
- current_sum = input()
- if current_sum == 'End':
- break
- current_sum = int(current_sum)
- # Проверка за Възможна транзакция
- if check_cash and current_sum <= 100:
- print('Product sold!')
- cash_sum.append(current_sum)
- check_need_sum -= current_sum
- check_cash = False
- if check_need_sum < 0:
- break
- elif not check_cash and current_sum >= 10:
- print('Product sold!')
- card_sum.append(current_sum)
- check_need_sum -= current_sum
- check_cash = True
- if check_need_sum < 0:
- break
- else:
- print('Error in transaction!')
- if check_cash:
- check_cash = False
- elif not check_cash:
- check_cash = True
- if not len(card_sum):
- aver_card = 0
- elif not len(cash_sum):
- aver_cash = 0
- else:
- aver_cash = sum(cash_sum) / len(cash_sum)
- aver_card = sum(card_sum) / len(card_sum)
- if current_sum == 'End':
- print('Failed to collect required money for charity.')
- else:
- print(f'Average CS: {aver_cash:.2f}')
- print(f'Average CC: {aver_card:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement