svephoto

Fruit Market [Python]

Feb 13th, 2022 (edited)
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. strawberry_price = float(input())
  2. bananas_weight = float(input())
  3. oranges_weight = float(input())
  4. raspberry_weight = float(input())
  5. strawberry_weight = float(input())
  6.  
  7. # raspberry_price_for_one_kilo = 24 - Неправилно задаване цената на малините
  8. # strawberry_price_for_one_kilo = raspberry_price_for_one_kilo * 2 - Неправилно пресмятане цената на ягодите
  9.  
  10. # По условие цената на малините е на половина по-ниска от тази на ягодите => пресмятаме я така:
  11. raspberry_price_for_one_kilo = strawberry_price / 2
  12. # Не трябва да делим на 100
  13. oranges_price_for_one_kilo = raspberry_price_for_one_kilo - (raspberry_price_for_one_kilo * 0.4)  # / 100
  14. # И тук не трябва да делим на 100
  15. bananas_price_for_one_kilo = raspberry_price_for_one_kilo - (raspberry_price_for_one_kilo * 0.8)  # / 100
  16.  
  17. total_sum_of_raspberries = raspberry_weight * raspberry_price_for_one_kilo
  18. total_sum_of_oranges = oranges_weight * oranges_price_for_one_kilo
  19. total_sum_of_bananas = bananas_weight * bananas_price_for_one_kilo
  20. # total_sum_of_strawberries = strawberry_weight * strawberry_price_for_one_kilo - Неправилно пресмятане
  21. # пълната цена на ягодите
  22. total_sum_of_strawberries = strawberry_weight * strawberry_price
  23.  
  24. needed_cash = total_sum_of_raspberries + total_sum_of_oranges + total_sum_of_bananas + total_sum_of_strawberries
  25.  
  26. print(f"{needed_cash:.2f}")  # Трябва да форматираме крайния резултат до втория знак след десетичната запетая.
  27.  
Add Comment
Please, Sign In to add comment