This is the basic structure of a Python class.
>>> class Simplex: ... "An example class""" ... def __init__(self, x, y): ... self.a = x ... self.b = y ... def addition(self): ... return self.a + self.b ... >>> z = Simplex(3,4) >>> z.a, z.b (3, 4) >>> z.addition() 7 >>> z.__doc__ 'An example class' >>> |
- I created the class
- Instantiated the class and gave 3 and 4 as parameters.
- Call a method
- Test out __doc__
I liked this session. I am new to Python, but would love to learn more.