Advertisement
webbersof

Untitled

Oct 23rd, 2022
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import math
  2.  
  3. budget = float(input())
  4. students = int(input())
  5. price_pack_flour = float(input())
  6. price_one_egg = float(input())
  7. price_one_apron = float(input())
  8. free_flour = len([i for i in range(1, students + 1) if i % 5 == 0]) # Тук взимам размера на листа, което реално е броя free flour
  9. # free_flour = 0
  10. #
  11. # for i in range(1, students + 1):
  12. # if i % 5 == 0:
  13. # free_flour += 1
  14.  
  15. # egg_price = (price_one_egg * 10) * students
  16. # flour_price = price_pack_flour * (students - free_flour)
  17. # apron_price = math.ceil((price_one_apron * students) + (students * 1.2))
  18. # all_price = apron_price + egg_price + flour_price
  19. # needed = abs(all_price - budget)
  20.  
  21. total_price = price_one_apron * (students + math.ceil(students * 0.20)) + (price_one_egg * 10 * students) \
  22. + (price_pack_flour * (students - free_flour))
  23.  
  24. if total_price <= budget:
  25. print(f"Items purchased for {total_price:.2f}$.")
  26.  
  27. else:
  28. diff = abs(total_price - budget)
  29. print(f"{diff:.2f}$ more needed.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement