Advertisement
exDotaPro

27_july_2019_6_baking_competition

Jan 5th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. cookies = 0
  2. cakes = 0
  3. waffles = 0
  4. total_sweeties = 0
  5.  
  6. current_cookies = 0
  7. current_cakes = 0
  8. current_waffles = 0
  9.  
  10. current_competitor = ''
  11. next_competitor = False
  12.  
  13. competitors = int(input())
  14.  
  15. for i in range(1, competitors + 1):
  16.  
  17.     command = input()
  18.  
  19.     while command != 'Stop baking!':
  20.         competitor_name = command
  21.         sweetie_type = input()
  22.  
  23.         if sweetie_type == 'Stop baking!':
  24.             next_competitor = True
  25.             break
  26.  
  27.         sweetie_type_count = int(input())
  28.         current_competitor = competitor_name
  29.  
  30.         if sweetie_type == 'cookies':
  31.             current_cookies += sweetie_type_count
  32.             cookies += sweetie_type_count
  33.             total_sweeties += sweetie_type_count
  34.         elif sweetie_type == 'cakes':
  35.             current_cakes += sweetie_type_count
  36.             cakes += sweetie_type_count
  37.             total_sweeties += sweetie_type_count
  38.         elif sweetie_type == 'waffles':
  39.             current_waffles += sweetie_type_count
  40.             waffles += sweetie_type_count
  41.             total_sweeties += sweetie_type_count
  42.  
  43.     if next_competitor:
  44.         print(f'{current_competitor} baked {current_cookies} cookies, {current_cakes} cakes and {current_waffles} waffles.')
  45.         current_cookies = 0
  46.         current_cakes = 0
  47.         current_waffles = 0
  48.  
  49. COOKIES_PRICE = 1.50 * cookies
  50. CAKES_PRICE = 7.80 * cakes
  51. WAFFLES_PRICE = 2.30 * waffles
  52.  
  53. for_charity = COOKIES_PRICE + CAKES_PRICE + WAFFLES_PRICE
  54.  
  55. print(f'All bakery sold: {total_sweeties}')
  56. print(f'Total sum for charity: {for_charity:.2f} lv.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement