Предмет: Информатика, автор: proggarmer

100 Балллоовв!


Вам дается текстовый файл, содержащий некоторое количество непустых строк.
На основе него сгенерируйте новый текстовый файл, содержащий те же строки в обратном порядке.

Пример входного файла:
ab
c
dde
ff

Пример выходного файла:
ff
dde
c
ab

Решите задачу на python

отправьте только результат кода

Приложения:

ГАЗ52: А что там в файле?
proggarmer: там случайные значения как ab
c
dde
ff
proggarmer: просто суть перевернуть файл чтобы было ff
dde
c
ab но там конечно другие значения

Ответы

Автор ответа: TemaZpro
1

Название текстового файла должно быть: input.txt. Результат будет в файле output.txt.

Код на языке Python:

with open('input.txt', 'r') as file:

   lines = file.readlines()

lines = [line.strip() for line in lines]

reversed_lines = lines[::-1]

with open('output.txt', 'w') as file:

   for line in reversed_lines:

       file.write(line + '\n')


proggarmer: чел я не знаю как еще тебе отблагодарить ты бог питона
proggarmer: пожалуйста можешь решить еще другие задания 2 задания из моего профиля
proggarmer: пожалуйста
proggarmer: они 100 балльные
proggarmer: https://znanija.com/task/53188826 и https://znanija.com/task/53188809 пж
TemaZpro: Сейчас гляну, постараюсь решить
proggarmer: спасибо огромное
Интересные вопросы
Предмет: Английский язык, автор: CaramelAnna
Activity # 1: Complete the sentences with the third conditional
1. If a meteorite ............................( not fall) in Mexico, many dinosaurs ................................. ( not disappear)
2. If the nuclear reactor in Chernobyl ...............................( not explode), so many people .........................................(not die)
3. If a volcano .................................... (not erupt) in the Mediterranean island of Stroggli around 1500 B.C, it ..........................................(not wipe) out the entire Minoan civilization.
4. The city's citadel........................................... (not collapse) across Aleppo on Oct. 11, 1138 if an earthquake ............................................. (not shake) the area.
5. If Haiti ..............................................( not be) so poor, the earthquake on January, 2010 ............................................................... ( not cause) so many deaths.
6. If a magnitude-9 temblor.............................................( not strike) undersea off the west coast of Sumatra on Dec. 26, 2004,it .............................................. ( not create) a massive
tsunami.
7. The Coringa cyclone of 1839 ..............................................(not destroy) about 20,000
ships and vessels if it .............................................( not hit) the port city of Coringa.
8. Heavy rains...................................................... (not inundate) 13,000 square kilometers
of land in the late 1880s if the Chinese ......................................( build) well the artificial
dikes around the Yellow River.
9. If a severe draught......................................(not hit) Bengal in 1770, it ..............................
....................( not cause) what is known as The Great Bengal Famine.
10. The Flu Pandemic of 1918 ....................................( not kill) between 20-50 million people
if the World War II ................................... ( not start)

Допоможіть !!!! Будь-ласка
Предмет: Математика, автор: zaneflynt