首页 > 解决方案 > 二维矩阵python增量

问题描述

我正在尝试在 python 中创建一个函数,它将 2D 矩阵中的每个值增加 10%。

import numpy
def add_percent(mtrx):
    for i in mtrx:
        for j in i:
            mtrx[i][j] += 1.1


test_mat = np.array([[86, 70, 80, 89],[92, 85, 87, 87],[73, 77, 94, 83]])

test_case = add_percent(test_mat)

它给我一个错误

标签: pythonnumpymatrix-multiplication

解决方案


推荐阅读