desislava_topuzakova

5. Грижи за кученце

May 22nd, 2021
1,357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # проверка дали закупеното покрива изяденото
  2. bought_food_kg = int(input())
  3. bought_food_gr = bought_food_kg * 1000
  4.  
  5. total_eaten_gr = 0 # общо колко е изяло
  6. command = input() # грамове или Adopted
  7. # stop: command == "Adopted" -> command != "Adopted"
  8. while command != "Adopted":
  9.     # изядени грамове -> command = "120" -> 120
  10.     eaten_gr = int(command)
  11.     total_eaten_gr += eaten_gr
  12.     command = input()
  13. else: #command == "Adopted"
  14.     # проверка дали закупеното е достатъчно
  15.     if bought_food_gr >= total_eaten_gr:
  16.         left_food = bought_food_gr - total_eaten_gr
  17.         print(f'Food is enough! Leftovers: {left_food} grams.')
  18.     else:
  19.         need_food = total_eaten_gr - bought_food_gr
  20.         print(f"Food is not enough. You need {need_food} grams more.")
  21.  
Advertisement
Add Comment
Please, Sign In to add comment