How to create class and object in Python?


Warning: Trying to access array offset on false in /home3/indiakep/public_html/wp-content/plugins/dw-question-answer/inc/Template.php on line 8
All QuestionsCategory: PythonHow to create class and object in Python?
Chetan Shidling asked 6 years ago

I need short information.

2 Answers
Chetan Shidling answered 6 years ago

Ok, I will share one example where I will create two objects and one class.
 
class laptop:
      def config(self):
             print(“i5, 16gb, 1TB”)
 
com1 = laptop()
com2 = laptop()
 
laptop.config(com1)
laptop.config(com2)
 
com1 and com2 are the two objects. laptop is a class.

Chetan Shidling answered 6 years ago

The output of above code will be;
 
i5, 16gb, 1TB
i5, 16gb, 1TB