用for循環(huán)實(shí)現(xiàn)
L=[1, 2, 3], [5, 3, 2], [7, 3, 2]?
i=0?
for i<3: ??
? s=2*L[i][0]*L[i][1]+2*L[i][0]*L[i][2]+2*L[i][1]*L[i][2] ??
? print (s) ? ?
為什么會(huì)出錯(cuò)呢
L=[1, 2, 3], [5, 3, 2], [7, 3, 2]?
i=0?
for i<3: ??
? s=2*L[i][0]*L[i][1]+2*L[i][0]*L[i][2]+2*L[i][1]*L[i][2] ??
? print (s) ? ?
為什么會(huì)出錯(cuò)呢
2021-01-20
舉報(bào)
2021-04-10
A=[1, 2, 3]
B=[5, 3, 2]
C=[7, 3, 2]
L=[A,B,C]
for i in range(3):
??? lon=L[i][0]
??? wei=L[i][1]
??? hig=L[i][2]
??? S=lon*wei*2+wei*hig*2+hig*lon*2
??? print(S)
2021-01-20
1.??? for i<3: 更換成for i in range(0,3):
2.??? 任務(wù)要求是三個(gè)立方體各個(gè)表面積?程序中的S更換成s[i],還需要在前面是聲明變量s=[0,0,0]
2021-01-20
你list的定義錯(cuò)了,外層少了中括號(hào)
應(yīng)該是 L=[[1, 2, 3], [5, 3, 2], [7, 3, 2] ]