Advertisement
webbersof

Untitled

Oct 31st, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1. from math import ceil
  2.  
  3. days = int(input())
  4. food = float(input())
  5.  
  6. food_eaten_total = 0
  7. biscuits_eaten_total = 0
  8. food_eaten_dog_total = 0
  9. food_eaten_cat_total = 0
  10.  
  11. #   Защо ти е това, вместо да ползваш променливата от цикъла за брой дни ?
  12. #   d = 0
  13.  
  14. for day in range(1, days + 1):
  15.     food_eaten_dog = int(input())
  16.     food_eaten_cat = int(input())
  17.     #   d += 1
  18.  
  19.     food_eaten_dog_total += food_eaten_dog
  20.     food_eaten_cat_total += food_eaten_cat
  21.     food_eaten_day = food_eaten_dog + food_eaten_cat
  22.     food_eaten_total += food_eaten_day
  23.  
  24.     if day % 3 == 0:
  25.         #   Нямаш нужда от тази променлива, абсолютно излишно е
  26.         #   biscuits_eaten_day = (food_eaten_day * 0.10)
  27.         biscuits_eaten_total += food_eaten_day * 0.10
  28.  
  29.  
  30. percent_eaten_food = (food_eaten_total / food) * 100
  31. percent_eaten_dog = (food_eaten_dog_total / food_eaten_total) * 100
  32. percent_eaten_cat = (food_eaten_cat_total / food_eaten_total) * 100
  33.  
  34. print(f"Total eaten biscuits: {round(biscuits_eaten_total)}gr.")
  35. print(f"{percent_eaten_food:.2f}% of the food has been eaten.")
  36. print(f"{percent_eaten_dog:.2f}% eaten from the dog.")
  37. print(f"{percent_eaten_cat:.2f}% eaten from the cat.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement