27 lines
878 B
Python
27 lines
878 B
Python
|
import os
|
|||
|
from math import sqrt
|
|||
|
|
|||
|
def find_largest_number_and_square():
|
|||
|
input_file = "/var/data/data.txt"
|
|||
|
output_file = "/var/result/result.txt"
|
|||
|
|
|||
|
try:
|
|||
|
with open(input_file, 'r') as f:
|
|||
|
numbers = [float(num.strip()) for num in f]
|
|||
|
|
|||
|
largest_num = max(numbers)
|
|||
|
squared_num = largest_num ** 2
|
|||
|
|
|||
|
with open(output_file, 'w') as f:
|
|||
|
f.write(str(squared_num))
|
|||
|
|
|||
|
print(f"Наибольшее числовое значение: {largest_num}")
|
|||
|
print(f"Результат: {squared_num}")
|
|||
|
except FileNotFoundError:
|
|||
|
print(f"Ошибка: Файл {input_file} не найден")
|
|||
|
except ValueError:
|
|||
|
print("Ошибка: В файле содержатся некорректные данные")
|
|||
|
|
|||
|
if __name__ == "__main__":
|
|||
|
find_largest_number_and_square()
|