May-30-2019, 09:53 AM
(This post was last modified: May-30-2019, 09:53 AM by KranthiYamanki.)
I am new to Python.
I have written a class for declaration of a parabola. When i am trying to access the class it is showing the error " 'int' object has no attribute 'x' ".
Please help with this code.
Thanks
I have written a class for declaration of a parabola. When i am trying to access the class it is showing the error " 'int' object has no attribute 'x' ".
Please help with this code.
Thanks
class Parabola:
def __init__(self,c0,c1,c2):
self.c0=c0
self.c1=c1
self.c2=c2
def __call__(self,x):
return self.c2*x**2+self.c1.x+self.c0
def table(self,L,R,n):
s=''
import numpy as np
for x in np.linspace(L,R,n):
y=self(x)
s+='%12g%12g\n'%(x,y)
return s
p=Parabola(1,-2,2)
p1=p(x=2)
print(p.table(0,2,10))
