Sichanov

rttt

Dec 4th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. funds_needed = int(input())
  2. funds_collected = 0
  3. command = input()
  4. payments_count = 0
  5. paid_by_cash = 0
  6. total_paid_by_cash = 0
  7. paid_by_card = 0
  8. total_paid_by_card = 0
  9. while command != "End":
  10.     product_price = int(command)
  11.     payments_count += 1
  12.     if payments_count % 2 == 0:
  13.         if product_price >= 10:
  14.             paid_by_card += 1
  15.             total_paid_by_card += product_price
  16.             funds_collected += product_price
  17.             print('Product sold!')
  18.         else:
  19.             print('Error in transaction!')
  20.     else:
  21.         if product_price <= 100:
  22.             paid_by_cash += 1
  23.             total_paid_by_cash += product_price
  24.             funds_collected += product_price
  25.             print('Product sold!')
  26.         else:
  27.             print('Error in transaction!')
  28.     if funds_collected >= funds_needed:
  29.         average_by_cash = total_paid_by_cash / paid_by_cash
  30.         average_by_card = total_paid_by_card / paid_by_card
  31.         print(f'Average CS: {average_by_cash:.2f}')
  32.         print(f'Average CC: {average_by_card:.2f}')
  33.         break
  34.     command = input()
  35. if funds_collected < funds_needed:
  36.     print('Failed to collect required money for charity.')
  37.  
Advertisement
Add Comment
Please, Sign In to add comment