def first(matrix): m = matrix[1::2] return map(sum, zip(*m)) def second(string): res = 0 for word in string.split(' '): l = len(word) if l > res: res = l return res from math import tan, pow, sin, cos def ss(i, j): a = pow(sin(i), 2) + pow(cos(j), 2) b = (i - 5) / (j+1) c = pow(a, b) d = (i - 5) / (j+1.5) f = 7.45 * tan(d) return c + f def generate_matrix(n, m): column = [] for i in range(n): row = [] for j in range(m): row.append(ss(i, j)) column.append(row) return column def sum_of_rows(matrix): res = [] for row in matrix: r= sum(row) res.append(r) return res def function(matrix): max_element = max(max(row) for row in matrix) result = [] for i in range(len(matrix)): row = matrix[i] result_row = [] for j in range(len(row)): result_row.append(max_element - i*j) result.append(result_row) return result # ------------- # - test - # ------------- matrix = generate_matrix(3,3) print matrix print first(matrix) row = 'sfsdfsd, sfsd f fsd f ffffff ss' print second(row) print sum_of_rows(matrix) print function(matrix)