Python class
class Student: # .. class variables, class by class variables (Student.classroom) class or instance variables (a.classroom) invoke Classroom = ' rocket class ' DEF the __init__ (Self, name, Age): # Self representative of the class examples, self.name = name represented Student incoming instantiating instances when the parameter assignment to the class name of the name attribute of the self.name = name self.age = Age DEF show_info (Self): Print ( ' I'm% s year years% s ' % (the self.name, self.age)) A = Student ( ' Scola ' , 39 ) a.show_info ()
Output:
My name is Luis Scola, 39 years old
self that are instances of classes
When creating instances a = Student ( 'Scola', 39), is performed by default def __init __ () method,
Passing in a parameter of the process, self.name = name represented by the incoming 'Scola' assigned to the name attribute assigned to an instance of self.name i.e.