From a6999dfe76e699f35d1179b00dd5d225fb20246c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B8=D0=B7=D0=B0=D0=B2=D0=B5=D1=82=D0=B0=20?= =?UTF-8?q?=D0=A1=D1=8E=D0=B7=D0=B5=D0=B2=D0=B0?= Date: Tue, 4 Mar 2025 12:38:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20data.txt,=20scr?= =?UTF-8?q?ipt.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Часть 3/.gitignore | 1 + Часть 3/data.txt | 5 +++++ Часть 3/script.py | 13 +++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 Часть 3/.gitignore create mode 100644 Часть 3/data.txt create mode 100644 Часть 3/script.py diff --git a/Часть 3/.gitignore b/Часть 3/.gitignore new file mode 100644 index 0000000..059d53c --- /dev/null +++ b/Часть 3/.gitignore @@ -0,0 +1 @@ +output.txt \ No newline at end of file diff --git a/Часть 3/data.txt b/Часть 3/data.txt new file mode 100644 index 0000000..b6c26bd --- /dev/null +++ b/Часть 3/data.txt @@ -0,0 +1,5 @@ +Бананы +Творог +Йогурт +Вишня +Чай \ No newline at end of file diff --git a/Часть 3/script.py b/Часть 3/script.py new file mode 100644 index 0000000..ecc4cea --- /dev/null +++ b/Часть 3/script.py @@ -0,0 +1,13 @@ +# Открываем data.txt и читаем содержимое +with open("data.txt", "r", encoding="utf-8") as file: + lines = file.readlines() + +# Преобразуем данные: переводим в верхний регистр и сортируем +processed_lines = sorted(line.strip().upper() for line in lines) + +# Записываем результат в output.txt +with open("output.txt", "w", encoding="utf-8") as file: + for line in processed_lines: + file.write(line + "\n") + +print("Файл output.txt успешно создан!")