This post will demonstrate use of the Python reserved word class.
Take a look at the following class called “PartyAnimal”.
Class is a reserved word that you will use for making python objects. Class remembers the template for an object.
The above picture demonstrates a template for making objects.
The variable “x” will be part of every instance of this class.
After the variable, you have a method with a name (“party”) and parameter (“self”). By convention, “self” is always the first parameter. More parameters can follow.
You can then call the object, put it in the variable “an”. At this point, “an” is an object. You can do things to it based on the definition of the class. Essentially “an.party()” is a short form of “PartyAnimal.party(an)”.
If you run the code, it will output the following:
The variable “self” acts as alias to “an”. It is like “self.x” is saying “x within self”.
Now, every string has all of the below methods.