yordan_yordanov

#1

Nov 7th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import math
  2.  
  3. budget = float(input())
  4. students = int(input())
  5. flour_price = float(input())
  6. egg_price = float(input())
  7. apron_price = float(input())
  8.  
  9. free_pack = 0
  10. flour_discount = free_pack * flour_price
  11. total_flour_price = (students * flour_price) - flour_discount
  12. total_egg_price = egg_price * 10 * students
  13. total_aprons_price = apron_price * (math.ceil(students * 1.2))
  14.  
  15. for student in range(1, students + 1):
  16.  
  17. if student % 5 == 0:
  18. free_pack += 1
  19.  
  20. total_price = total_flour_price + total_egg_price + total_aprons_price
  21.  
  22. if total_price <= budget:
  23. print(f"Items purchased for {total_price:.2f}$.")
  24. else:
  25. print(f"{abs(budget - total_price):.2f}$ more needed.")
  26.  
Advertisement
Add Comment
Please, Sign In to add comment