Problem scenario
You inherited code from a different programmer. You want to test out an object. How do you create an object of a pre-made class?
Solution
Look at how many variables the class has. Take this code for example:
class Cartesian(object):
def __init__(self,a = 0,b = 0):
self.a = a
self.b = b
def distance(self):
return (self.a**2 + self.b**2) ** 0.5 # Pythagorean theorem. …
Continue reading “How Do You Instantiate a class in Python?”