jeudi 13 février 2020

Hi i am trying to split the values in a (y2)list into (inv) amount of parts and I keep getting wrong values in some parts

Hi I am trying to split the values in a (y2)list into (inv) amount of parts and I keep getting wrong values in some parts could you please check my code. My answer is slightly more than what is required

x = [0,100,200,300,400,500,600,700,800,900,1000,1100]
y2 = [58,55,49,12,6,5,4,4.5,35,48,56,58]
interval = 5
inv = (x[0] + x[1])/interval


A = []

for i in range(len(y2)-1):
    C= y2[i]

    if C > y2[i+1]:
            while C>= y2[i+1]:
              C= C- ((y2[i]-y2[i+1])/inv)
              A += [C]

    else:
            while C<= y2[i+1]:
              C= C+ ((y2[i+1]-y2[i])/inv)
              A += [C]

print(A)

Aucun commentaire:

Enregistrer un commentaire