Написан скрипт на питоне по заданию 1 часть 3

This commit is contained in:
Алексей Сырчин 2025-03-05 12:24:34 +03:00
parent 6fc7146863
commit 2909e92a35
4 changed files with 23 additions and 2 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
.venv/ .venv/
output.txt

View File

@ -1 +1,3 @@
Задание по Python Задание по Python
Прочитать файл data.txt, поменять регистр букв и записать рещультат в output.txt

2
data.txt Normal file
View File

@ -0,0 +1,2 @@
Hello World
Hello Sailor

16
script.py Normal file
View File

@ -0,0 +1,16 @@
def convert_case(text):
return text.swapcase()
def main():
with open('data.txt', 'r') as file:
data = file.read()
converted_data = convert_case(data)
with open('output.txt', 'w') as file:
file.write(converted_data)
print("Регистр букв изменён. Результат записан в output.txt")
if __name__ == "__main__":
main()