Advertisement
exDotaPro

27_july_2019_6_trip_expenses

Jan 5th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. trip_days = int(input())
  2.  
  3. day_balance = 60
  4. products_bought = 0
  5.  
  6. for days in range(1, trip_days + 1):
  7.  
  8.     while day_balance > 0:
  9.         command = input()
  10.  
  11.         if command == 'Day over':
  12.             print(f'Money left from today: {day_balance:.2f}. You\'ve bought {products_bought} products. ')
  13.             day_balance += 60
  14.             products_bought = 0
  15.             break
  16.  
  17.         product_price = float(command)
  18.  
  19.         if product_price > day_balance:
  20.             continue
  21.  
  22.         else:
  23.             day_balance -= product_price
  24.             products_bought += 1
  25.  
  26.             if day_balance == 0:
  27.                 day_balance += 60
  28.                 print(f'Daily limit exceeded! You\'ve bought {products_bought} products.')
  29.                 products_bought = 0
  30.                 break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement