当前位置:网站首页>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↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
边栏推荐
- Example 045: Summation
- Completion of the flag set in 2022
- 数据挖掘和数据仓库之间的区别
- ArcGIS Advanced (1) - Install ArcGIS Enterprise and create an sde library
- SQLserver加个判断
- what is eabi
- 【图像分类】2022-ResMLP
- IDEA自动生成serialVersionUID
- Introduction and application of quantitative trading strategies
- GDB command basic parameters
猜你喜欢
flink 12 源码编译及使用idea运行、debug
Will signal with different start time alignment
The Evolutionary History of the "Double Gun" Trojan Horse Virus
ECCV 2022 Oral | CCPL: 一种通用的关联性保留损失函数实现通用风格迁移
自动化测试中,测试数据与脚本分离以及参数化方法
liunx PS1 设置
MySQL:你做过哪些MySQL的优化?
实例043:作用域、类的方法与变量
将信号与不同开始时间对齐
[Kali Security Penetration Testing Practice Course] Chapter 9 Wireless Network Penetration
随机推荐
Little rookie Hebei Unicom induction training essay
2022.8.8考试摄像师老马(photographer)题解
Research on IC enterprises
网页挖矿溯源?浏览器浏览历史查看工具Browsinghistoryview
FusionCompute产品介绍
实例045:求和
On the Harvest of Travel
将信号与不同开始时间对齐
How Microbes Affect Physical Health
【图像分类】2022-ConvMixer ICLR
【Kali安全渗透测试实践教程】第8章 Web渗透
liunx PS1 settings
【红队】ATT&CK - 自启动 - 利用LSA身份验证包自启动机制
剑指offer专项突击版第25天
2022.8.8考试区域链接(district)题解
Chip Accelerator
小菜鸟河北联通上岗培训随笔
T5: Text-to-Text Transfer Transformer
[8.8] Code Source - [Non-falling subarray game] [Longest rising subsequence count (Bonus)] [Substring (data enhanced version)]
2022.8.8考试清洁工老马(sweeper)题解