Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def convert_safely(value, type):
- result = None
- try:
- result = type(value)
- except Exception:
- result = None
- return result
- with open('input.txt') as f:
- A = [[convert_safely(x, int) for x in line.split()] for line in f]
- for arr in A:
- if None in arr:
- raise TypeError("Не могу прочитать матрицу. Проверьте введенные данные.")
- A = np.matrix(A)
- if A.shape[0] != A.shape[1]:
- raise Exception("Требуется квадратная матрица. Проверьте введенные данные.")
- N = A.shape[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement