开发者

Looping through lists with different number of elements

开发者 https://www.devze.com 2023-03-16 19:37 出处:网络
I have the right result in C=[ ] but I can´t get Tx equal to: [42, 68, 86] [23, 45, 59] 开发者_高级运维[40, 68, 85]

I have the right result in C=[ ] but I can´t get Tx equal to: [42, 68, 86] [23, 45, 59] 开发者_高级运维 [40, 68, 85] [30, 56, 72] This is the loop I can´t do. I think it´s easy but I´m new in this, and I can´t find a solution, every thing I need to do depends on this type of aproach. Give me a light if you can.

#T(1) = [T0 * C[1]+QIN[1]] multiply each element of T by each element of C adding each element of QIN
#T(2) = [T1 * C[2]+QIN[2]] multiply each element of T1 by each element of C2 adding each element of QIN2
#T(3) = [T2 * C[3]+QIN[3]] multiply each element of T2 by each element of C3 adding each element of QIN3
#T(4) = [T3 * C[4]+QIN[4]] multiply each element of T3 by each element of C3 adding each element of QIN4


QIN=[2.0, 3.0, 5.0, 2.0]
TIN=[10.0, 12.0, 13.0, 12.0] 

V=[2.0, 4.0, 5.0]

T0=[10.0, 11.0, 12.0]

for i in range(len(QIN)):
    C = []
    for v in V:
        C.append(v + QIN[i])
    print C 

for q in QIN:
    Tx = []
    for c in C:     
        for t in T0: 
            Tx.append(t * c + q)
    print Tx


Ts = [T0]
Tx = []
counter = 1
for T in Ts:
    for t in T:
        Ts.append([s[0] * s[1] + s[2] for s in izip(Ts[-1], C, QIN)])

I haven't tested this, so comment if it doesn't work

0

精彩评论

暂无评论...
验证码 换一张
取 消