DAS_2024_1/polevoy_sergey_lab_2/second/second.py

19 lines
685 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
# Указание путей к файлу данных и результирующему файлу
data_file = "/var/result/data.txt"
result_file = "/var/result/result.txt"
def power_greatest_number(source_file, result_file):
with open(source_file, mode="r") as file:
largest_number = max(int(number) for number in file.readlines())
with open(result_file, mode="w") as file:
file.write(str(largest_number ** 2))
print(f"В файл {result_file} записано наибольшее число во второй степени из файла {source_file}")
if __name__ == "__main__":
power_greatest_number(data_file, result_file)