from random import random
M = 10
N = 5
a = []
for i in range(N):
b = []
for j in range(M):
b.append(int(random() * 11))
print("%3d" % b[j], end = '')
a.append(b)
print(' |', sum(b))
for i in range(M):
print(" --", end = '')
print()
for i in range(M):
s = 0
for j in range(N):
s += a[j][i]
print("%3d" % s, end = '')
print()
x = [
['a', '3', '5', '7'],
['b', '1', '2', '3'],
['c', '1', '2', '3']
]
rotated = zip(*x[::-1])
for row in rotated:
l = [int(x) for x in row if x.isdigit()]
print sum(l)
>>> x = [['a', '3', '5', '7'], ['b', '1', '2', '3'], ['д', '1', '2', '3']]
>>> # сортируем по столбцам
>>> x_sort = list(zip(*x))
>>> x_sort
[('a', 'b', 'д'), ('3', '1', '1'), ('5', '2', '2'), ('7', '3', '3')]
>>> # убираем лишний кортеж (с буквами)
>>> x_sort = x_sort[1:]
>>> x_sort
[('3', '1', '1'), ('5', '2', '2'), ('7', '3', '3')]
>>> # переводим строки в числа
>>> x_to_int = [list(map(int, i)) for i in x_sort]
>>> x_to_int
[[3, 1, 1], [5, 2, 2], [7, 3, 3]]
>>> # ищем среднее, округляем до сотых
>>> x_avg_sum = ['{:.2f}'.format(sum(i)/3) for i in x_to_int]
>>> x_avg_sum
['1.67', '3.00', '4.33']
matrix = [
['a', '3', '5', '7'],
['b', '1', '2', '3'],
['c', '1', '2', '3'],
]
[sum(int(item) for item in column if item.isdigit()) for column in zip(*matrix)]
[sum(map(int, filter(str.isdigit, column))) for column in zip(*matrix)]