In short
A class is a blueprint for making objects that hold data and the functions that work on it. Special methods, with names like __init__ and __str__, let an object behave like a built-in type.
__init__ runs when an object is made and sets up its data. __str__ decides what print shows. Others such as __add__ let you use + with your own objects. The first parameter of every method is self, the object itself. Classes are useful in science to model a particle, a planet or a vector with its own properties.
This prints Ball of 0.5 kg.
Also searched as: python special methods.
Python labs run in your browser. Type the code, run it and see what happens.
Open a Python lab