class Person:
def __init__(self, first, last):
self.firstname = first
self.lastname = last
def __str__(self):
return self.firstname + " " + self.lastname
class Employee(Person):
def __init__(self, first, last, staffnum):
super().__init__(first, last)
self.staffnumber = staffnum
x = Person("Marge", "Simpson")
y = Employee("Homer", "Simpson", "1007")
print(x)
print(y)
Asked
Active
Viewed 66 times
-2
![](../../users/profiles/722804.webp)
Terry Jan Reedy
- 15,989
- 1
- 33
- 48
![](../../users/profiles/5659868.webp)
Delino
- 1,049
- 12
- 9
-
It's not really clear what you're asking. You should revisit your question and edit it in order to amend more information. Please see http://stackoverflow.com/help/how-to-ask – planetmaker Dec 09 '15 at 18:12
-
I changed title to a comprehensible question. If not right, explain better what you are asking. It is not clear why you posted the particular code you did. – Terry Jan Reedy Dec 09 '15 at 18:15
-
Yes you are right. i try running the codes on the IDLE but am having "invalid syntax" i was wondering if is happens to the type of version i have please i help me out i have a test study with this question on Andela institute..... – Delino Dec 13 '15 at 06:51
-
the question is an example i needed to practice but each time i run it in my python IDLE it returns "invalid syntax" – Delino Dec 13 '15 at 06:52
1 Answers
1
Answering what I think you mean.
Start IDLE either from icon or command line. Detail depend on OS and a bit on Python version.
Load file into an IDLE editor window using File => Open menu option and the open-file dialog. If a file had been edited recently, use File => Recent files.
Edit as you wish. Run with Run => Run module or use F5 shortcut.
If you start IDLE from a command line, optionally add a file path, either relative or absolute, to open the file directly and skip the File menu.
![](../../users/profiles/722804.webp)
Terry Jan Reedy
- 15,989
- 1
- 33
- 48