当前位置:网站首页>Example 044: Matrix Addition
Example 044: Matrix Addition
2022-08-10 03:32:00 【lazily】
Title: Calculate the addition of two matrices.
Program analysis: Create a new matrix, use for to iterate and take out the values of the corresponding positions in the X and Y matrices, add them and put them in the corresponding positions of the new matrix.
I. Code
X = [[12, 7, 3],[4, 5, 6],[7, 8, 9]]Y = [[5, 8, 1],[6, 7, 3],[4, 5, 9]]res = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]for i in range(len(res)):for j in range(len(res[0])):res[i][j] = X[i][j] + Y[i][j]print(res)Second, the execution result

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓Lazy laughter and sincerityInvite you to click below to learn and discuss together↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
边栏推荐
猜你喜欢

HRnet

MySQL:日志系统介绍 | 错误日志 | 查询日志 | 二进制日志:bin-log数据恢复实践 | 慢日志查询

Database management tool: dynamic read-write separation

【Kali安全渗透测试实践教程】第9章 无线网络渗透

【Kali安全渗透测试实践教程】第6章 密码攻击

数据在内存中的存储

HACKTHEBOX——Bank

【Image Classification】2022-ConvMixer ICLR
![[Kali Security Penetration Testing Practice Course] Chapter 7 Privilege Escalation](/img/fe/c1aebd4a9f8be29820af35c79d6332.png)
[Kali Security Penetration Testing Practice Course] Chapter 7 Privilege Escalation

【Image Classification】2022-ResMLP
随机推荐
2022杭电多校联赛第七场 题解
【红队】ATT&CK - 自启动 - 利用LSA身份验证包自启动机制
Introduction and application of quantitative trading strategies
Pagoda server PHP+mysql web page URL jump problem
实例043:作用域、类的方法与变量
what is eabi
实例045:求和
【二叉树-中等】1261. 在受污染的二叉树中查找元素
微生物是如何影响身体健康的
6 common plugin recommendations in Pycharm
官宣出自己的博客啦
推荐几款好用的MySQL开源客户端,建议收藏
IDEA自动生成serialVersionUID
What is a Cross-Site Request Forgery (CSRF) attack?How to defend?
跨站请求伪造(CSRF)攻击是什么?如何防御?
量化交易策略介绍及应用市值中性化选股
excel高级绘图技巧100讲(二十三)-Excel中实现倒计时计数
what is a microcontroller or mcu
2022.8.8 Exam questions for photographer Lao Ma (photographer)
web crawler error