- #1

Freya

- 15

- 1

n= int(input("How many data points do you have for the polynomial="))for d in range (1, n+1):

x = float(input ("Enter 1st x value x"))

y = float(input ("Enter 1st y value y"))

yi =0e0for i in range (1, n+1):

p=1e0for j in range (1, n+1):if(j != i):

p *=(xi-x[j])/(x

*-x[j])*

yi += p*y

yi += p*y

print(yi)

but I need a way of having the user input the number of coordinates they have (n) and then using this information, the points they input take up the role of x[1] y[1]... up to x[n+1] and y[n+1] but I don't have a clue how to do this. I should probably mention we are not aloud to use .scipy or such add ons, we must do it all from scratch.print(yi)

but I need a way of having the user input the number of coordinates they have (n) and then using this information, the points they input take up the role of x[1] y[1]... up to x[n+1] and y[n+1] but I don't have a clue how to do this. I should probably mention we are not aloud to use .scipy or such add ons, we must do it all from scratch.