Sfoglia il codice sorgente

Добавить '2_31.py'

u23-27kovalenko 1 mese fa
parent
commit
a402f50c4b
1 ha cambiato i file con 13 aggiunte e 0 eliminazioni
  1. 13 0
      2_31.py

+ 13 - 0
2_31.py

@@ -0,0 +1,13 @@
+candy = float(input("Введите стоимость 1 кг конфет: "))
+biscuit = float(input("Введите стоимость 1 кг печенья: "))
+apple = float(input("Введите стоимость 1 кг яблок: "))
+
+x = float(input("Введите количество кг конфет: "))
+y = float(input("Введите количество кг печенья: "))
+z = float(input("Введите количество кг яблок: "))
+total = candy * x + biscuit * y + apple * z
+
+with open("result.txt", "w", encoding="utf-8") as file:
+    file.write(f"Общая стоимость покупки: {total:.2f} рублей\n")
+
+print("Результат записан в файл result.txt")