Skip to main content

Thread: Python Help


i'm new using classes in python, python in general, , i'm not sure i'm doing wrong this. i'm hoping can tell me how fix this.

code:
class cp:  	x = x/1000  	def o2(self, x):  		self.state = 30.03235 + 8.772972*x + (-3.988133*x**2) + (0.788313*x**3) - 0.741599/(x**2)  	def n2(self, x):  		self.state = 19.50583 + 19.88705*x + (-8.598535*x**2) + (1.369784*x**3) + 0.527601/(x**2)  print(cp.o2(1500))

quote posted elfo33 view post
i'm new using classes in python, python in general, , i'm not sure i'm doing wrong this. i'm hoping can tell me how fix this.

code:
class cp:     x = x/1000     def o2(self, x):         self.state = 30.03235 + 8.772972*x + (-3.988133*x**2) + (0.788313*x**3) - 0.741599/(x**2)     def n2(self, x):         self.state = 19.50583 + 19.88705*x + (-8.598535*x**2) + (1.369784*x**3) + 0.527601/(x**2) print(cp.o2(1500))
you calling method on class , not instance of class. try

code:
c = cp() print(c.o2(1500))
edit: didn't enough, there more problems: functions o2 , n2 should return value if want print something.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Python Help


Ubuntu

Comments

Popular posts from this blog

Could not place because the source rectangle is empty

Thread: Using smartcard reader with vpnc

Adobe Font Folio 7.0 or just 7?