当前位置:网站首页>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↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
边栏推荐
- How Microbes Affect Physical Health
- excel高级绘图技巧100讲(二十三)-Excel中实现倒计时计数
- 网页挖矿溯源?浏览器浏览历史查看工具Browsinghistoryview
- 2022.8.9 Exam Unique Bid Auction--800 Question Solutions
- HACKTHEBOX——Bank
- 2022强网杯 Quals Reverse 部分writeup
- State compression small experience
- 【Kali安全渗透测试实践教程】第6章 密码攻击
- 微生物是如何影响身体健康的
- 【Image Classification】2022-ResMLP
猜你喜欢
随机推荐
【Kali安全渗透测试实践教程】第7章 权限提升
算法与语音对话方向面试题库
GDB之指令基础参数
【Image Classification】2022-ResMLP
Chapter 21 Source Code File REST API Reference (3)
Pycharm中6个常用插件推荐
2022.8.8考试游记总结
【红队】ATT&CK - 自启动 - 注册表运行键、启动文件夹
【Kali安全渗透测试实践教程】第6章 密码攻击
【二叉树-中等】1104. 二叉树寻路
推荐几款好用的MySQL开源客户端,建议收藏
实例043:作用域、类的方法与变量
第二十一章 源代码文件 REST API 参考(三)
控制台中查看莫格命令的详细信息
GDB command basic parameters
2022.8.9 Exam Cube Sum--1100 Question Solutions
[8.8] Code Source - [Non-falling subarray game] [Longest rising subsequence count (Bonus)] [Substring (data enhanced version)]
HRnet
实例046:打破循环
深度学习(五) CNN卷积神经网络




![[Kali Security Penetration Testing Practice Course] Chapter 9 Wireless Network Penetration](/img/7d/c621680ac73e2987f023a2e98e01df.png)




