---python 3.9---
# массив
m = [[1, 4, 5],
[0, 0, 1]]
# a - сумма всех чисел; b - кол-во чисел
a = 0
b = 0
for row in m:
for cell in row:
if cell != 0:
a += cell
b += 1
sredn = float(a / b)
for row_n, row in enumerate(m):
for cell_n, cell in enumerate(row):
if cell == 0:
m[row_n][cell_n] = sredn
numbers = [1,2,3,0,0,0,0,0,0,5]
average = sum(numbers) / len(numbers)
numbers = [average if i == 0 else i for i in numbers]
print(numbers)
---python 3.9---
# массив
m = [[1, 4, 5],
[0, 0, 1]]
# a - сумма всех чисел; b - кол-во чисел
a = 0
b = 0
for row in m:
for cell in row:
if cell != 0:
a += cell
b += 1
sredn = float(a / b)
for row_n, row in enumerate(m):
for cell_n, cell in enumerate(row):
if cell == 0:
m[row_n][cell_n] = sredn
numbers = [1,2,3,0,0,0,0,0,0,5]
average = sum(numbers) / len(numbers)
numbers = [average if i == 0 else i for i in numbers]
print(numbers)