问答详情
源自:5-8 Python二维list

有没有分别显示之后,在显示三个表面积之和

L=[[1, 2, 3], [5, 3, 2], [7, 3, 2]]

for c in L:

    lenght=c[0]

    width=c[1]

    height=c[2]

    s=2*lenght*width+2*lenght*height+2*width*height

    print(s)


提问者:qq_慕慕4538939 2024-09-05 14:02

个回答

  • qq_慕侠3039784
    2024-09-10 09:08:03

    L = [[1,2,3], [5, 3, 2], [7,3,2]]

    N=3

    s=0

    if N>=1:

        for cube in L:

            length = cube[0]

            width = cube[1]

            height = cube[2]

            result = length * width * 2 + width * height * 2 + length * height * 2

            print(result)

            s=s+result

            N=N-1

        print(s)