I\'m trying to learn python and I now I am trying to get the hang of classes and how to manipulate them with instances.
I can\'t seem to understand this practice pro
Create a class and give it an __init__
method:
class Student:
def __init__(self, name, age, major):
self.name = name
self.age = age
self.major = major
def is_old(self):
return self.age > 100
Now, you can initialize an instance of the Student
class:
>>> s = Student('John', 88, None)
>>> s.name
'John'
>>> s.age
88
Although I'm not sure why you need a make_student
student function if it does the same thing as Student.__init__
.