Preview lessons, content and tests

Computer Science & Programming solved. All in one platform.

1. To trial the platform and take tests, please take a few seconds to SIGN UP and SET UP FREE.

2. Searching for something specific? See our text overview of all tests. Scroll right for levels, and lists.

3. Student and Teacher User Guides |  Schemes of Work |   Real Teacher use Videos |


Join 36000+ teachers and students using TTIO.

Instantiation and putting it all together

It may be helpful to think of a class as a factory for making objects. The class itself isn’t an instance of a point, but it contains the machinery to make point instances. Every time we call the constructor, we’re asking the factory to make us a new object. As the object comes off the production line, its initialization method is executed to get the object properly set up with its factory default settings.

The combined process of “make me a new object” and “get its settings initialized to the factory default settings” is called instantiation. Instantiating a class is creating a copy of the class which inherits all class variables and methods. Instantiating a class in Python is simple. To instantiate a class, we simply call the class as if it were a function, passing the arguments that the __init__ method defines.


PowerPoint - create a class based library system


Solution Video

Putting it altogether - creating instances of classes that interact in a whole system. Watch the following video and follow along to create your own class based library system. 


Create Object (Create an instance of a class)

Below is a demonstration of how we can use the class named MyClass to create objects:

Example: Create an object named p1, and print the value of x:

p1 = MyClass()
print(p1.x)

Try it Yourself »

www.teachyourselfpython.com