interviewbit with Python questions solutions

class Student:
    def __init__(self, name, branch):
        self.name = name
        self.branch = branch
obj = Student("Robin", "CSE")
print(obj.name)
print(obj.branch)

Here is what the above code is Doing:
1. We created a class named Student.
2. We defined the __init__() function. This function is called automatically every time the class is being used to create a new object.
3. The __init__() function is used to assign values to object properties, or other operations that are necessary to do when the object is being created.
4. The self parameter is a reference to the current instance of the class, and is used to access variables that belongs to the class.
5. We created an object named obj.
6. We printed the value of the name property.
7. We printed the value of the branch property.