Sichanov

food pets

Apr 19th, 2021
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. days = int(input())
  2. amount_food = float(input())
  3. days_num = 0
  4. num_food_cat = 0
  5. num_food_dog = 0
  6. cookie_cat = 0
  7. cookie_dog = 0
  8. for c in range(1, days + 1):
  9.     dog = int(input())
  10.     cat = int(input())  # добавяме изядена храна от котката
  11.     days_num += 1  # броим дните в отчета
  12.     if days < days_num:  # ако отчетените дни надвишават заложените като срок
  13.         break
  14.     elif days_num % 3 != 0:
  15.         num_food_cat += cat  # сумираме изядената храна от котката
  16.         num_food_dog += dog
  17.     if days_num % 3 == 0:  # маркираме всеки 3-ти ден
  18.         cookie_cat += cat * 0.1  # заделяме 10% от общата храна за бисквитките
  19.         cookie_dog += dog * 0.1  # math.ceil() закръглено до най–близкото цяло число
  20.         num_food_cat += cat  # сумираме изядената храна от котката
  21.         num_food_dog += dog
  22. print(f"Total eaten biscuits: {round(cookie_cat + cookie_dog)}gr.")
  23. print(f"{(num_food_cat + num_food_dog) / amount_food * 100:.2f}% of the food has been eaten.")
  24. print(f"{(num_food_dog) / (num_food_cat + num_food_dog) * 100:.2f}% eaten from the dog.")
  25. print(f"{(num_food_cat) / (num_food_cat + num_food_dog) * 100:.2f}% eaten from the cat.")
Advertisement
Add Comment
Please, Sign In to add comment