Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- budget = float(input())
- students = int(input())
- price_pack_flour = float(input())
- price_one_egg = float(input())
- price_one_apron = float(input())
- free_flour = len([i for i in range(1, students + 1) if i % 5 == 0]) # Тук взимам размера на листа, което реално е броя free flour
- # free_flour = 0
- #
- # for i in range(1, students + 1):
- # if i % 5 == 0:
- # free_flour += 1
- # egg_price = (price_one_egg * 10) * students
- # flour_price = price_pack_flour * (students - free_flour)
- # apron_price = math.ceil((price_one_apron * students) + (students * 1.2))
- # all_price = apron_price + egg_price + flour_price
- # needed = abs(all_price - budget)
- total_price = price_one_apron * (students + math.ceil(students * 0.20)) + (price_one_egg * 10 * students) \
- + (price_pack_flour * (students - free_flour))
- if total_price <= budget:
- print(f"Items purchased for {total_price:.2f}$.")
- else:
- diff = abs(total_price - budget)
- print(f"{diff:.2f}$ more needed.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement