Advertisement
webbersof

Untitled

Jan 18th, 2022
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. budget = float(input())
  2. price_floor = float(input())
  3.  
  4. number_of_bread = 0
  5. colored_eggs = 0
  6. money_left = budget
  7. # Няма никакъв смисъл от това
  8. # have_budget = True
  9.  
  10. price_eggs = (price_floor * 0.75)
  11. price_milk = (price_floor * 1.25 / 4)
  12. price_one_bread = price_floor + price_eggs + price_milk
  13.  
  14. while True:
  15.     # Тази проверка трябва да е в началото на цикъла,
  16.     # тъй като ако няма достатъчно пари, няма смисъл да извършваш долните изчисления
  17.     if money_left < price_one_bread:
  18.         # -----Излишна променлива-----
  19.         # have_budget = False
  20.         break
  21.     # ------- Това е константа и не може да взимаш на всяка итерация на цикъла цена за всички съставки и
  22.     # съответно рецептата да се конструира всеки път. Тя се прави веднъж в началото и извън цикъла.
  23.     # Рецептата и цената за един хляб се прави веднъж като изчисление.
  24.     # price_eggs = (price_floor * 0.75)
  25.     # price_milk = (price_floor * 1.25 / 4)
  26.     # price_one_bread = price_floor + price_eggs + price_milk
  27.     money_left -= price_one_bread
  28.     number_of_bread += 1
  29.     colored_eggs += 3
  30.  
  31.     if number_of_bread % 3 == 0:
  32.         colored_eggs -= number_of_bread - 2
  33.  
  34.     # if money_left < price_one_bread:
  35.         # -----Излишна променлива-----
  36.         # have_budget = False
  37.         # break
  38.  
  39. print(f"You made {number_of_bread} loaves of Easter bread! Now you have "
  40.       f"{colored_eggs} eggs and {money_left:.2f}BGN left.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement