5/27/2023 0 Comments Python class![]() Print(self.name, self.roll_no, Student.school_name) ![]() Note: We should change the class variable’s value using the class name only. However, we can change the value of the class variable either in the class or outside of class. Generally, we assign value to a class variable inside the class declaration. In this example, we accessed the class variable school_name using class name and a self keyword inside a method. Print(self.name, self.roll_no, self.school_name) # access class variable inside constructor using selfĮxample 2: Access Class Variable in Instance method and outside class class Student:
0 Comments
Leave a Reply. |