DAS_2024_1/vaksman_valeria_lab_2/app_two/Second.py
2024-10-01 19:42:31 +04:00

19 lines
677 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.

# Пути к директориии c файлами для поиска и сохранения
input_file = '/var/result/data.txt'
output_file = '/var/result/result.txt'
# Поиск наименьшего числа в файле
with open(input_file, 'r') as f:
numbers = [float(line.strip()) for line in f if line.strip()]
# Искомое min число
min_number = min(numbers)
cubed_number = min_number ** 3
# Сохранение
with open(output_file, 'w') as f:
f.write(str(cubed_number))
print(f"Наименьшее число: {min_number}\nЕго третья степень: {cubed_number}\nРезультат сохранён в {output_file}")