Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # проверка дали закупеното покрива изяденото
- bought_food_kg = int(input())
- bought_food_gr = bought_food_kg * 1000
- total_eaten_gr = 0 # общо колко е изяло
- command = input() # грамове или Adopted
- # stop: command == "Adopted" -> command != "Adopted"
- while command != "Adopted":
- # изядени грамове -> command = "120" -> 120
- eaten_gr = int(command)
- total_eaten_gr += eaten_gr
- command = input()
- else: #command == "Adopted"
- # проверка дали закупеното е достатъчно
- if bought_food_gr >= total_eaten_gr:
- left_food = bought_food_gr - total_eaten_gr
- print(f'Food is enough! Leftovers: {left_food} grams.')
- else:
- need_food = total_eaten_gr - bought_food_gr
- print(f"Food is not enough. You need {need_food} grams more.")
Advertisement
Add Comment
Please, Sign In to add comment