In this tutorial, we will learn python in detail.
Since Python is an object-oriented programming language all the code is written using a special construct called class. Developers use classes to make related things together. This can be done using the keyword ‘class’. A Class is an object constructor. It is blueprint for creating objects.
Create a class:
Use the keyword ‘class’ to create class.
x = 10
x = 5
p1 = MyClass()
The _init_() function:
Every class has a function called _init_(), which will be executed when the class is being initiated.
Values can be assigned to object properties using _init_().
def __init__(self, name, age):
self.name = name
self.age = age
p1 = Person("John", 36)