Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- budget = float(input())
- price_floor = float(input())
- number_of_bread = 0
- colored_eggs = 0
- money_left = budget
- # Няма никакъв смисъл от това
- # have_budget = True
- price_eggs = (price_floor * 0.75)
- price_milk = (price_floor * 1.25 / 4)
- price_one_bread = price_floor + price_eggs + price_milk
- while True:
- # Тази проверка трябва да е в началото на цикъла,
- # тъй като ако няма достатъчно пари, няма смисъл да извършваш долните изчисления
- if money_left < price_one_bread:
- # -----Излишна променлива-----
- # have_budget = False
- break
- # ------- Това е константа и не може да взимаш на всяка итерация на цикъла цена за всички съставки и
- # съответно рецептата да се конструира всеки път. Тя се прави веднъж в началото и извън цикъла.
- # Рецептата и цената за един хляб се прави веднъж като изчисление.
- # price_eggs = (price_floor * 0.75)
- # price_milk = (price_floor * 1.25 / 4)
- # price_one_bread = price_floor + price_eggs + price_milk
- money_left -= price_one_bread
- number_of_bread += 1
- colored_eggs += 3
- if number_of_bread % 3 == 0:
- colored_eggs -= number_of_bread - 2
- # if money_left < price_one_bread:
- # -----Излишна променлива-----
- # have_budget = False
- # break
- print(f"You made {number_of_bread} loaves of Easter bread! Now you have "
- f"{colored_eggs} eggs and {money_left:.2f}BGN left.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement