+ 1

How do you inherent on python

So i made a rough copy of what i got on Pycharm, it runs and prints out the Welcome statements. Now when it excutes student.Welcome () instead of printing : "Welcome (users name) (users last name) your gpa is (users gpa) and your grad year is (users grad year). It prints out like "Welcome . Your gpa is (users gpa) and grad year is (users grad year)" not displaying the users first or last name and im trying to figure out why? Any idea why. Code doesnt run on solo learn but i assure it runs on Pycharm or ecplise https://code.sololearn.com/c6vlsUYu8tiE/?ref=app

24th Nov 2019, 3:00 AM
marcus
marcus - avatar
1 Answer
+ 3
In line 50 you should write student.Welcome() with lowercase s Otherwise you try to invoke a classmethod, but this is an instance method (it must have an instance of the Student class to work, because it has the self parameter. The instance is student (lowercase). You are creating two different instances: person and student. They are different and independent from each other. You only gave a name to person, and only gave a score to student. Inheritance is about enabling the child class, to use the parent's methods. So you can do this: marcus = Student() marcus.First_Name("marcus") And you don't need to create any instances of the Person class (unless you want to represent the teacher or the janitor).
24th Nov 2019, 5:35 AM
Tibor Santa
Tibor Santa - avatar