Implement a simple Student class
Implementing a class is very simple. First, create a file (this step is not necessary, but for convenience), called student.py and then start writing code.
class Student(object):
pass
This is a class. Pass means do nothing. For convenience, fill in the code here later.
Then we add a method. init()
class Student(object):
def __init__(self, name, score):
self.name = name
self.score = score
Note: There are two underscores on both sides of init.
The init() method is the constructor, which is automatically called when the object is instantiated. The first self is required and represents itself.