大头目
发表于 2018-2-28 10:25:12
x = [,
,
]
y = [,
,
]
z1 = [*3]*3 #z定义法一
z2 = [, #z定义法二
,
]
print(z1)
print(z2)
for i in range(3):
for j in range(3):
z1 = x + y
z2 = x + y
print(z1,x,y)
print(z2,x,y)
print(x)
print(y)
print(z1)
print(z2)
结果咧
发表于 2018-2-28 20:34:01
def getjvzheng():
x=[,,]
for i in range(3):
for j in range(3):
x=int(input('请输入第%d行第%d列:'%(i+1,j+1)))
return x
def calc(list1,list2):
list3=[,,]
for i in range(3):
for j in range(3):
list3=list1*list2+list1*list2+list1*list2
return list3
print('请输入矩阵a:')
a=getjvzheng()
print('\n请输入矩阵b:',end=('\n'))
b=getjvzheng()
c=calc(a,b)
def pr(y):
for i in range(3):
for j in range(3):
print(y,end=' ')
print('\n')
print('\n')
pr(a)
print('----------')
pr(b)
print('----------')
pr(c)
好吧,只能这样了
瞬秒爆加速
发表于 2018-3-5 16:46:00
import copy
X = [,
,
]
Y = [,
,
]
Z = copy.deepcopy(X)
for i,j in zip(X,Y):
for ii,jj in zip(i,j):
Z = ii+jj
else:
print(Z)
benzhj
发表于 2018-3-8 14:14:00
X = [,
,
]
Y = [,
,
]
Z = []
for i in range(3):
temp = []
for x in range(3):
temp.append(X + Y)
Z.append(temp)
print (Z)
Charonnnnn
发表于 2018-3-16 19:18:58
lala
小酒酒
发表于 2018-4-6 21:29:13
99592938 发表于 2017-3-30 11:53
>>>
[, , ]
老哥,你这个是真的稳。我和你用了一样的思路,但是在嵌套的列表那儿还是迷了,看了你的,真心佩服
tsembrace
发表于 2018-4-7 16:15:27
#两个 3 行 3 列的矩阵,实现其对应位置的数据相加,并返回一个新矩阵
def addlist(la,lb):
listx=la
for i in range(len(la)):
for j in range(len(la)):
listx=(la+lb)
return listx
la=[,,]
lb=[,,]
print(addlist(la,lb))
天天学习$
发表于 2018-4-26 20:14:00
i = 0
j = 0
x = [,,]
y = [,,]
list_new1 = []
list_new2 = []
for i in range(0,3):
for j in range(0,3):
temp = x + y
list_new2.append(temp)
list_new1.append(list_new2)
list_new2 = []
print(list_new1)
萧丹夜
发表于 2018-5-9 12:12:42
X = [,
,
]
Y = [,
,
]
Z = []
for i in range(0,3):
a = []
for j in range(0,3):
a.append(X + Y)
Z.append(a)
print(Z)
张大哈
发表于 2018-6-15 10:14:38
import numpy as np
x = np.array([,,])
y = np.array([,,])
z = x + y
print(z)
看看答案
Milo_Ye
发表于 2018-7-21 10:59:45
4141
小强工作室
发表于 2018-7-29 10:30:20
def rflat(lst):#一维列表二维化
return list(zip(**3))#数字可以变化
def flat(lst):#多维转一维
return if isinstance(lst,(list,tuple)) else
if __name__=="__main__":
list1 = [, , ]
list2 = [, , ]
list3=[]
for i in range(9):
list3.append(flat(list1)+flat(list2))
print(rflat(list3))
CC柴
发表于 2018-7-31 11:34:31
x = [,
,
]
y = [,
,
]
for i in range(3):
for j in range(3):
x = x + y
print(x)
602328322
发表于 2018-7-31 15:32:06
学习学习
Nyu菌
发表于 2018-8-2 22:12:57
看看答案......
一步半个脚印
发表于 2018-8-23 22:49:28
x = [,
,
]
y = [,
,
]
z=[]
for i in range(3):
z.append([])
for j in range(3):
z.append(x + y)
print(z)
acgods
发表于 2018-8-24 10:02:44
X = [,
,
]
Y = [,
,
]
z = []
for i in range(3):
for j in range(3):
z.append(X * Y)
print(, z, z])
quan-renda
发表于 2018-8-25 18:11:56
X = [,
,
]
Y = [,
,
]
lst=[]
for a in range(len(X)):
lst1=[]
for b in range(len(X)):
n=X+Y
lst1.append(n)
lst.append(lst1)
print(lst)
我不会啊
发表于 2018-8-30 14:46:42
赞
冷焰溶冰
发表于 2018-9-9 18:51:17
X = [,
,
]
Y = [,
,
]
z=[]
print(X)
for i in range(len(X)):
z.append([])
for j in range(len(X)):
z.append(X+Y)
print(z)