-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_boilerplate.py
27 lines (22 loc) · 1.05 KB
/
main_boilerplate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from typing import Callable
MIN = 2
def create_dataset(get_line: Callable[..., str]):
x = list(map(float, get_line().replace(',', '.').split()))
y = list(map(float, get_line().replace(',', '.').split()))
if len(x) != len(y) or len(x) <= MIN:
print(f"Введите корректную таблицу, содержащую не менее {MIN} точек.")
return None
return [x, y]
def read_initial_data():
while True:
filename = input("Введите имя файла для загрузки исходных данных и интервала "
"или пустую строку, чтобы ввести вручную: ")
try:
input_function = input if filename == '' else open(filename, "r").readline
dataset = create_dataset(input_function)
if dataset is not None:
return dataset
except FileNotFoundError:
print('Файл не найден.')
except:
print('Что-то пошло не так.')